Input Text disabled Property - Find out if a text field is disabled or not: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Input Text disabled Property - Find out if a text field is disabled or not:

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() {/*  w ww  .  j av a  2s.c om*/
    document.getElementById("myText").disabled = true;
    var v = document.getElementById("myText").disabled;
    console.log(v);
}

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

</body>
</html>

Related Tutorials