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:To prevent users from interacting with this field, use disabled attribute.
See also:
HTML Reference Manual:HTML <input> readonly-attribut
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 property:
inputdateObject.readOnly
Set readOnly property:
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 , annars returneras false . |
---|
Webbläsarstöd
Numrerna i tabellen anger den första webbläsarversionen som helt stöder detta attribut.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Stöd | 10.0 | Stöd | Stöd | Stöd |
Observera:Elementet <input type="date"> visar inget datumfält/kalender i IE11 och tidigare versioner.