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