Disable a month field:
document.getElementById("myMonth").disabled = true;
Click the button to disable the month field.
<!DOCTYPE html> <html> <body> <input type="month" id="myMonth"> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w .j av a2s . c o m*/ document.getElementById("myMonth").disabled = true; } </script> </body> </html>
The disabled property sets or gets whether a month field should be disabled, or not.
This property mirrors the HTML disabled attribute.
The <input type="month"> element is not supported in Firefox.
The disabled property accepts and returns a boolean value.
Value | Description |
---|---|
true | The month field is disabled |
false | Default. The month field is not disabled |
The disabled property returns true if the month field is disabled, otherwise it returns false.