Javascript examples for DOM HTML Element:Input Password
The maxLength property sets or gets the maxlength attribute of a password field, which controls the maximum number of characters allowed in a password field.
Set the maxLength property with the following Values
Value | Description |
---|---|
integer | Sets the maximum number of characters allowed in the password field |
A Number, representing the maximum number of characters allowed in the password field
The following code shows how to get the maximum number of characters allowed in a specific password field:
<!DOCTYPE html> <html> <body> Password: <input type="password" id="myPsw"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww.java 2s .co m var v = document.getElementById("myPsw").maxLength; document.getElementById("demo").innerHTML = v; } </script> </body> </html>