The HTML DOM Input Datetime disabled property sets/returns whether Input Datetime is enabled or disabled.
Following is the syntax −
inputDatetimeObject.disabled
inputDatetimeObject.disabled = booleanValue
Here, “booleanValue” can be the following −
booleanValue | Details |
---|---|
true | It defines that the input datetime is disabled. |
false | It defines that the input datetime is not disabled and it is also the default value. |
Let us see an example of Input Datetime disabled property −
<!DOCTYPE html> <html> <head> <title>Input Datetime Disabled</title> </head> <body> <form> Date & Time: <input type="datetime" id="datetimeSelect" value="1998-04-09T12:48IST" disabled> </form> <button onclick="enableDatetimeInput()">Enable Datetime Input</button> <div id="divDisplay"></div> <script> var divDisplay = document.getElementById("divDisplay"); var inputDatetime = document.getElementById("datetimeSelect"); divDisplay.textContent = 'Datetime Input disabled: '+inputDatetime.disabled; function enableDatetimeInput() { inputDatetime.disabled = false; divDisplay.textContent = 'Datetime Input disabled: '+inputDatetime.disabled; } </script> </body> </html>
This will produce the following output −
Before clicking ‘Enable Datetime Input’ button −
After clicking ‘Enable Datetime Input’ button −