Input Date readOnly attribute
Definition and usage
readOnly
Sets or returns whether the date field should be read-only.
You cannot modify the read-only field. However, users can select it, highlight it, and copy text from it.
This property reflects the HTML readonly attribute.
Tip:If you want to prevent users from interacting with this field, use disabled attribute.
See also:
HTML Reference Manual:HTML <input> readonly Attribute
Instance
Example 1
Set the date field to read-only:
document.getElementById("myDate").readOnly = true;
Example 2
Check if the date field is read-only:
var x = document.getElementById("myDate").readOnly;
Syntax
Return readOnly attribute:
inputdateObject.readOnly
Set readOnly attribute:
inputdateObject.readOnly = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specifies whether the date field should be read-only
|
Technical details
Return value: | Boolean value, returns if the date field is read-only true , otherwise return false . |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Note:The <input type="date"> element does not display any date field/calendar in IE11 and earlier versions.