Input Number disabled Property - Disable and enable a number field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

Input Number disabled Property - Disable and enable a number field

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="number" id="myNumber" value="2"><br><br>

<button onclick="disableBtn()">Disable Number Field</button>
<button onclick="enableBtn()">Enable Number Field</button>

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

</body>
</html>

Related Tutorials