Input Month disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Month

Description

The disabled property sets or gets whether a month field should be disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether a month field should be disabled
  • true - The month field is disabled
  • false - Default. The month field is not disabled

Return Value

A Boolean, returns true if the month field is disabled, otherwise it returns false

The following code shows how to disable a month field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="month" id="myMonth"><br><br>

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

<script>
function disableBtn() {//  w ww  .j a  v a  2 s . co  m
    document.getElementById("myMonth").disabled = true;
}
function enableBtn() {
    document.getElementById("myMonth").disabled = false;
}
</script>

</body>
</html>

Related Tutorials