maxlength
收藏:0
阅读:44
Password maxLength 属性
定义和用法
maxLength 属性可设置或返回密码域中所允许的最大字符数。
语法
设置 maxLength 属性:
passwordObject.maxLength=integer
返回 maxLength 属性:
passwordObject.maxLength
浏览器支持
所有主要浏览器都支持 maxLength 属性
实例
下面的例子可显示指定的密码域中所允许的最大字符数:
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("pwd").maxLength;
alert(x);
}
</script>
</head>
<body>
<form>
Password: <input type="password" id="pwd" maxlength="8">
</form>
<button type="button" onclick="displayResult()">Display max number of characters allowed</button>
</body>
</html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("pwd").maxLength;
alert(x);
}
</script>
</head>
<body>
<form>
Password: <input type="password" id="pwd" maxlength="8">
</form>
<button type="button" onclick="displayResult()">Display max number of characters allowed</button>
</body>
</html>