Password size 屬性

定義和用法
size 屬性可設(shè)置或者返回密碼域的的寬度(數(shù)字字符)。
默認值為 20。
語法
設(shè)置 size 屬性:
passwordObject.size=integer
返回 size 屬性:
passwordObject.size
瀏覽器支持
所有主要瀏覽器都支持 size 屬性
實例
實例
設(shè)置密碼域的寬度:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function setResult(){
document.getElementById("pwd").size=40;
}
</script>
</head>
<body>
<form>
密碼: <input type="password" id="pwd">
</form>
<button type="button" onclick="setResult()">設(shè)置寬度</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在線教程(w3cschool.cn)</title>
<script>
function setResult(){
document.getElementById("pwd").size=40;
}
</script>
</head>
<body>
<form>
密碼: <input type="password" id="pwd">
</form>
<button type="button" onclick="setResult()">設(shè)置寬度</button>
</body>
</html>
嘗試一下 ?

更多建議: