Input Date readOnly Property

Input Date Object Reference Input Date Object

Example

Set the date field to read-only:

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

Output:

Try it yourself Β»


Definition and Usage

The readOnly property is used to return whether a date field is read-only or to set it.

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 the disabled property instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

The readOnly property is supported in all major browsers.

Note: Internet Explorer and Firefox do not support the <input type="date"> element.


Syntax

Return the readOnly property:

inputdateObject.readOnly

Set the readOnly property:

inputdateObject.readOnly=true|false

Property Values

Value Description
true|false Specifies whether the date field is read-only:
  • true - The date field is read-only.
  • false - Default. The date field is not read-only.

Technical Details

Return Value:
A Boolean. Returns true if the date field is read-only, otherwise false.

More Examples

Example

Check if the date field is read-only:

var x = document.getElementById("myDate").readOnly;

The value of x will be:

true

Try it yourself Β»


Related Articles

HTML Reference: HTML <input> readonly Attribute


Input Date Object Reference Input Date Object