HTML DOM maxLength 屬性
定義和用法
maxLength 屬性可設置或返回密碼域中所允許的最大字符數(shù)。
語法
passwordObject.maxLength=number_of_chars
實例
下面的例子可顯示指定的密碼域中所允許的最大字符數(shù):
<html>
<head>
<script type="text/javascript">
function alertLength()
{
alert(document.getElementById("password1").maxLength
)
}
</script>
</head>
<body>
<form>
<input type="password" id="password1" maxLength="8" />
<input type="button" id="button1" onclick="alertLength()"
value="Alert maxLength" />
</form>
</body>
</html>