Javascript examples for DOM HTML Element:Input Date
The disabled property sets or gets whether a date field is disabled.
This property reflects the HTML disabled attribute.
Set the disabled property with the following Values
Value | Description |
---|---|
true|false | Sets whether a date field should be disabled |
A Boolean, returns true if the date field is disabled, otherwise it returns false
The following code shows how to disable a date field:
<!DOCTYPE html> <html> <body> <input type="date" id="myDate"><br><br> <button onclick="disableBtn()">Disable Date Field</button> <button onclick="undisableBtn()">Enable Date Field</button> <script> function disableBtn() {//from w w w. j av a 2 s .c om document.getElementById("myDate").disabled = true; } function undisableBtn() { document.getElementById("myDate").disabled = false; } </script> </body> </html>