Latest web development tutorials

HTML DOM Input Month readOnly property

Input Month Object Reference Input Month Object


Month field is set to read-only:

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


try it"

Definition and Usage

readOnly property sets or returns the month whether the field is read-only.

Read-only fields can not be modified. But you can copy the contents of the field.

This property reflects the HTML readonly attribute.

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

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support readOnly property.

Note: Internet Explorer or Firefox browser does not support type = "month" <input> element attributes.


Back readOnly attributes:

monthObject .readOnly

Set readOnly properties:

monthObject .readOnly=true|false

Property Value

true|false 描述了 month 字段是否只读
  • true - month 字段为只读
  • false - 默认。 month 字段不是只读

technical details

return value: Boolean value that, if the field is read-month returns true, otherwise returns false.

More examples


View month field is read-only:

var x = document.getElementById("myMonth").readOnly;
x The output is:

try it"

Related Pages

HTML Reference Manual: HTML <the INPUT> Readonly property

Input Month Object Reference Input Month Object