Javascript examples for DOM HTML Element:Input Password
The size property sets or gets the size attribute of a password field, which controls the width of a password field in number of characters.
The default value is 20.
Set the size property with the following Values
Value | Description |
---|---|
number | Sets the width of the password field, in characters. Default value is 20 |
A Number, representing the width of the password field, in characters
The following code shows how to change the width of a password field:
<!DOCTYPE html> <html> <body> Password: <input type="password" id="myPsw"> <button onclick="myFunction()">Test</button> <script> function myFunction() {// www . java2s . co m document.getElementById("myPsw").size = "50"; } </script> </body> </html>