Javascript DOM HTML Input Password readOnly Property get

Introduction

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.

View in separate window

<!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>



PreviousNext

Related