The disabled
property disables or enables a month field.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = monthObject.disabled
Set the disabled property.
monthObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a month field
|
A Boolean type value, true if the month field is disabled, otherwise false.
The following code shows how to check if a month field is disabled.
<!DOCTYPE html>
<html>
<body>
<!-- ww w . j av a 2s . c o m-->
<input type="month" id="myMonth" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myMonth").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enable a month field.
<!DOCTYPE html>
<html>
<body>
<!-- w w w . ja v a 2 s .c om-->
<input type="month" id="myMonth"><br><br>
<button onclick="disableBtn()">Disable Month Field</button>
<button onclick="enableBtn()">Enabled Month Field</button>
<script>
function disableBtn() {
document.getElementById("myMonth").disabled = true;
}
function enableBtn() {
document.getElementById("myMonth").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: