Javascript examples for DOM HTML Element:Input Datetime
The disabled property sets or gets whether a datetime 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 datetime field should be disabled |
A Boolean, returns true if the datetime field is disabled, otherwise it returns false
The following code shows how to disable a datetime field:
<!DOCTYPE html> <html> <body> <input type="datetime" id="myDatetime"><br><br> <button onclick="disableBtn()">Disable Datetime Field</button> <button onclick="enableBtn()">Enable Datetime Field</button> <script> function disableBtn() {/*from ww w . j ava2 s .com*/ document.getElementById("myDatetime").disabled = true; } function enableBtn() { document.getElementById("myDatetime").disabled = false; } </script> </body> </html>