Input Month readOnlyProperty

Input Month 对象参考手册Input Month Object

Examples

Set the month field to read-only:

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

Output:


Try it yourself »

Definition and Usage

The readOnly property is used to set or return whether the month field is read-only.

Read-only fields cannot be modified. However, the contents of the field can be copied.

This property reflects the HTML readonly attribute.

Tip:To ensure the accuracy of form data, you can use thedisabledattribute instead.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the readOnly property.

Note:Internet Explorer or Firefox browsers do not support <input> elements with the type="month" attribute.


Syntax

Return the readOnly property:

monthObject.readOnly

Set the readOnly property:

monthObject.readOnly=true|false

Property Values

Value Description
true|false Describes whether the month field is read-only
  • true - The month field is read-only
  • false - Default. The month field is not read-only

Technical Details

Return Value: A Boolean value, returning true if the month field is read-only, otherwise returning false.


More Examples

Example

Check whether the month field is read-only:

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

Try it yourself »


Related Pages

HTML Reference:HTML <input> readonly Attribute


Input Month 对象参考手册Input Month Object Other Extensions