Input DatetimeLocal readOnly Attribute
Definition and Usage
readOnly
Sets or returns whether the local date and time field should be read-only.
You cannot modify a read-only field. However, users can select it, highlight it, and copy text from it.
This property reflects the HTML readonly attribute.
Tip:To prevent users from interacting with the field, use disabled attribute.
See Also:
HTML Reference Manual:HTML <input> readonly Attribute
Example
Example 1
Set the local date and time field to read-only:
document.getElementById("myLocalDate").readOnly = true;
Example 2
Check if the local date and time field is read-only:
var x = document.getElementById("myLocalDate").readOnly;
Syntax
Return the readOnly property:
datetimelocalObject.readOnly
Set the readOnly property:
datetimelocalObject.readOnly = true|false
Attribute Value
Value | Description |
---|---|
true|false |
Specifies whether the local date and time field should be read-only
|
Technical Details
Return value: | Boolean value, returned if the local date and time 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="datetime-local"> element does not display any date/time field/calendar in Firefox.