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 Πρότυπο

Example

Example 1

Set the date field to read-only:

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

Try it yourself

Example 2

Check if the date field is read-only:

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

Try it yourself

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.

  • true - The date field is read-only
  • false - Default. The date field is not read-only

Technical details

Return value: Boolean value, if the date field is read-only, it returns true,έτσι επιστρέφει false.

Υποστήριξη Βrowser

Οι αριθμοί στη διάταξη σηματοδοτούν την έκδοση του προγράμματος περιήγησης που υποστηρίζει πλήρως την ιδιότητα.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Υποστήριξη 10.0 Υποστήριξη Υποστήριξη Υποστήριξη

ΛήψηΤο στοιχείο <input type="date"> δεν εμφανίζει καμία περιοχή ημερομηνίας/καレντάρι στις εκδόσεις IE11 και πιο παλιές.