Change the width of a password field:
document.getElementById("myPsw").size = "50";
Click the button to change the width of the password field.
<!DOCTYPE html> <html> <body> Password: <input type="password" id="myPsw"> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*ww w. ja va 2s. c o m*/ document.getElementById("myPsw").size = "50"; } </script> </body> </html>
The size property sets or gets the size attribute of a password field.
The size attribute sets the width of a password field in number of characters.
The default value is 20.
The size property accepts and returns a String type value.