HTML DOM maxLength 属性

定义和用法

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>
系统帮助 | 给我留言 | 收藏本站
Copyright © 2005-2008 www.cnn84.com All Rights Reserved Ver:2.0
CNN84网是公益性便民网站,是为了给大家的日常生活查询及提供最快捷的出行指南