HTML DOM Input Date readOnly Property
Input Date readOnly Property
Example
Set the date field to read-only:
document.getElementById("myDate").readOnly = true;
Output:
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
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:
|
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
Related Articles
HTML Reference: HTML <input> readonly Attribute
YouTip