Input Datetime disabled attribute

Definition and usage

disabled Attribute sets or returns whether the datetime field should be disabled.

Disabled elements are not available and cannot be clicked. By default, disabled elements are usually displayed in gray in the browser.

This property reflects the HTML disabled attribute.

See also:

HTML Reference Manual:HTML <input> disabled attribute

Instance

Example 1

Disable the datetime field:

document.getElementById("myDatetime").disabled = true;

Try it yourself

Example 2

Check if the datetime field is disabled:

var x = document.getElementById("myDatetime").disabled;

Try it yourself

Example 3

Disable and enable the datetime field:

function disableBtn() {
    document.getElementById("myDatetime").disabled = true;
}
function undisableBtn() {
    document.getElementById("myDatetime").disabled = false;
}

Try it yourself

Syntax

Return the disabled attribute:

datetimeObject.disabled

Set the disabled attribute:

datetimeObject.disabled = true|false

Attribute value

Value Description
true|false

Specifies whether the datetime field should be disabled.

  • true - The datetime field is disabled
  • false - Default. The datetime field is not disabled

Technical details

Return value: Boolean, returns if the datetime field is disabled true, otherwise return false.

Browser support

The numbers in the table indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="datetime"> element does not display any date-time field/calendar in any mainstream browser except Safari.