Javascript DOM HTML Input Email readOnly Property get

Introduction

Find out if an email field is read-only:

var x = document.getElementById("myEmail").readOnly;

Click the button to find out if the email field is read-only.

View in separate window

<!DOCTYPE html>
<html>
<body>

E-mail: <input type="email" id="myEmail" readonly>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*  w ww.  j  av  a2  s  .c o  m*/
  var x = document.getElementById("myEmail").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related