Password sizeProperty

Password 对象参考手册Password Object

Definition and Usage

The size property sets or returns the width of the password field (in number of characters).

The default value is 20.

Syntax

Set the size property:

passwordObject.size=integer

Return the size property:

passwordObject.size


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the size property


Example

Example

Set the width of the password field:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function setResult(){
    document.getElementById("pwd").size=40;
}
</script>
</head>
<body>

<form>
Password: <input type="password" id="pwd">
</form>
<button type="button" onclick="setResult()">Set width</button>

</body>
</html>

Try it yourself »


Password 对象参考手册Password Object Other Extensions