Javascript DOM HTML Input Text disabled Property get

Introduction

Find out if a text field is disabled or not:

var x = document.getElementById("myText").disabled;

Click the button to find out if the text field is disabled.

View in separate window

<!DOCTYPE html>
<html>
<body>

Name: <input type="text" id="myText">
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*  w ww. j  a  va  2s.  co m*/
  var x = document.getElementById("myText").disabled;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related