Disable a password field:
document.getElementById("myPsw").disabled = true;
Click the button to disable the password field.
<!DOCTYPE html> <html> <body> Password: <input type="password" id="myPsw"> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w .j a va 2 s.c om*/ document.getElementById("myPsw").disabled = true; } </script> </body> </html>
The disabled property sets or gets whether a password field should be disabled.
This property mirrors the HTML disabled attribute.
Value | Description |
---|---|
true | The password field is disabled |
false | Default. The password field is not disabled |
The disabled property returns true if the password field is disabled, otherwise it returns false.