Input DatetimeLocal readOnlyProperty

Input DatetimeLocal 对象参考手册Input DatetimeLocal Object

Example

Set the local time field to read-only:

document.getElementById("myLocalDate").readOnly = true;

Output:


Try it yourself »

Definition and Usage

The readOnly property is used to set or return whether the local time field is read-only.

A read-only field cannot be modified. However, the content of the field can be copied.

This property reflects the HTML readonly attribute.

Tip:To ensure the accuracy of form data, you can use thedisabledproperty instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The readOnly property is supported by all major browsers.

Note:Internet Explorer or Firefox browsers do not support the <input type="datetime-local"> element.


Syntax

Return the readOnly property:

datetimelocalObject.readOnly

Set the readOnly property:

datetimelocalObject.readOnly=true|false

Property Values

Value Description
true|false Describes whether the local time field is read-only.
  • true - The local time field is read-only
  • false - Default. The local time field is not read-only

Technical Details

Return Value: A Boolean value, returns true if the local time field is read-only, otherwise returns false.


More Examples

Example

Check whether the local time field is read-only:

var x = document.getElementById("myLocalDate").readOnly;
xThe output is:
true

Try it yourself »


Related Pages

HTML Reference Manual:HTML <input> readonly Attribute


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