Easy Tutorial
❮ Met Doc Open Dom Obj Text ❯

Input Date readOnly Attribute

Input Date Object

Example

Set the date field to read-only:

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

Output result:


Definition and Usage

The readOnly attribute is used to return or set whether the date field is read-only.

Read-only fields cannot be modified. However, their content can be copied.

This attribute reflects the HTML readonly attribute.

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


Browser Support

All major browsers support the readOnly attribute.

Note: The <input type="date"> element is not supported in Internet Explorer or Firefox browsers.


Syntax

Return the readOnly attribute:

Set the readOnly attribute:

Attribute Values

Value Description
true|false Describes whether the date field is read-only: true - The date field is read-only<br>false - Default. The date field is not read-only.

Technical Details

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


More Examples

Example

Check if the date field is read-only:

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

Related Articles

HTML Reference: HTML <input> readonly Attribute


❮ Met Doc Open Dom Obj Text ❯