Input Datetime disabledProperty

Input Datetime 对象参考手册Input Datetime Object

Examples

Disable the datetime field:

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

The output result is:


Try it Yourself »

Definition and Usage

The disabled property is used to set or return whether the datetime field is disabled.

Elements that use the disabled property are unavailable and unclickable. Disabled elements are usually displayed in gray in browsers.

This property reflects the HTML disabled attribute.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the disabled property.

Note:Internet Explorer, Firefox, Opera 15 (and later versions), or Chrome support the <input> element with type="datetime".


Syntax

Return the disabled property:

datetimeObject.disabled

Set the disabled property:

datetimeObject.disabled=true|false

Property Values

Value Description
true|false Describes whether the datetime field is available.
  • true - The datetime field is unavailable
  • false - Default. The datetime field is available

Technical Details

Return Value: A Boolean value, returns true if the datetime field is unavailable, otherwise returns false.


More Examples

Examples

Check whether the datetime field is available:

var x = document.getElementById("myDatetime").disabled;
xThe output result is:
true

Try it Yourself »

Examples

Disable and enable the datetime field:

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

Try it Yourself »


Related Pages

HTML Reference Manual:HTML <input> disabled Attribute


Input Datetime 对象参考手册Input Datetime Object Other Extensions