Input Datetime disabled attribute
Example
Disable the datetime field:
document.getElementById("myDatetime").disabled = true;
The output result is:
Try it »
Definition and Usage
The disabled attribute is used to set or return whether the datetime field is disabled.
Elements with the disabled attribute are unavailable and not clickable. Disabled elements are usually displayed in gray in the browser.
This attribute reflects the HTML disabled attribute.
Browser support





All major browsers support the disabled attribute.
Note: Supported by Internet Explorer, Firefox, Opera 15 (and later), or Chrome. element using type="datetime".
Syntax
Return the disabled attribute:
datetimeObject
.disabled
Set the disabled attribute:
datetimeObject
.disabled=true|false
Attribute values
| Value | Description |
|---|---|
| true|false | Describes whether the datetime field is available.
|
Technical Details
| Return Value: | Boolean value, returns true if the datetime field is unavailable, otherwise returns false |
|---|
More examples
Example
Check whether the datetime field is available:
var x = document.getElementById("myDatetime").disabled;
x
The output is:
true
Try it »
Example
Disable and enable the datetime field:
function disableBtn() {
document.getElementById("myDatetime").disabled = true;
}
function undisableBtn() {
document.getElementById("myDatetime").disabled = false;
}
Try it »
Related pages
HTML Reference Manual: HTML disabled attribute
Input Datetime Object