HTML DOM Input Month Object


Input Month Object

The Input Month object is new in HTML5.

The Input Month object represents an HTML <input> element with type="month".

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

Access an Input Month Object

You can use the getElementById() function to access an <input> element with the type="month" attribute:

var x = document.getElementById("myMonth"); Try it Yourself

Tip:You can also access the Input Month object through the form'selementscollection.

Create an Input Month Object

You can use the document.createElement() method to create an <input> element with the type="month" attribute:

var x = document.createElement("INPUT");
x.setAttribute("type", "month"); Try it Yourself

Input Month Object Properties

Property Description
autocomplete Sets or returns the autocomplete attribute value of a month field
autofocus Sets or returns whether a month field automatically gets focus when the page loads
defaultValue Sets or returns the default value of a month field
disabled Sets or returns whether a month field is disabled
form Returns a reference to the form that contains the month field
list Returns a reference to the datalist that contains the month field
max Sets or returns the max attribute value of a month field
min Sets or returns the min attribute value of a month field
name Sets or returns the name attribute value of a month field
readOnly Sets or returns whether a month field is read-only
required Sets or returns whether a month field is a required field in the form
step Sets or returns the step attribute value of a month field
type Returns the form element type of a month field
value Sets or returns the value attribute value of a month field

Standard Properties and Events

The Input Month object also supports standardpropertiesandevents。


Related Articles

HTML Tutorial:HTML Forms

HTML Reference Manual:HTML <input> Tag

HTML Reference Manual:HTML <input> type Attribute

Other Extensions