maxLength 属性可设置或返回密码域中所允许的最大字符数。
passwordObject.maxLength=number_of_chars
下面的例子可显示指定的密码域中所允许的最大字符数:
<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>