Input Month readOnly Attribute

Definition and Usage

readOnly Attribute to set or return whether the month field should be read-only.

You cannot modify the read-only field. However, users can select, 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

Instance

Example 1

Set the month field to read-only:

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

Try it yourself

Example 2

Check if the month field is read-only:

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

Try it yourself

Syntax

Return the readOnly property:

monthObject.readOnly

Set the readOnly property:

monthObject.readOnly = true|false

Attribute value

Value Description
true|false

Specify whether the month field should be read-only.

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

Technical Details

Return Value: Boolean value, if the month field is read-only, it will return true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="month"> element does not display any date field/calendar in Firefox.