Input Text disabled Property - Disable and enable a text field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Input Text disabled Property - Disable and enable a text field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

First Name: <input type="text" id="myText" value="Mickey"><br>

<button onclick="disableTxt()">Disable Text field</button>
<button onclick="enableTxt()">Enable Text field</button>

<script>
function disableTxt() {//from  w  w w  .j  a v a  2 s.  c o  m
    document.getElementById("myText").disabled = true;
}

function enableTxt() {
    document.getElementById("myText").disabled = false;
  }
</script>

</body>
</html>

Related Tutorials