Find out if a password field is read-only:
var x = document.getElementById("myPsw").readOnly;
Click the button to find out whether the password field is read-only.
<!DOCTYPE html> <html> <body> Password:<input type="password" id="myPsw" readonly> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// www. j a v a2 s . c om var x = document.getElementById("myPsw").readOnly; document.getElementById("demo").innerHTML = x; } </script> </body> </html>