<input> - month


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 or Firefox browsers do not support <input> elements with the type="month" attribute.

Access the Input Month object

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

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

 Try It! 

Tip: You can also access the Input Month object through the form's elements collection.

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! 

Input Month object properties

AttributeDescription
autocompleteSets or returns the value of the autocomplete attribute of the month field
autofocusSets or returns whether the month field automatically gets focus after page load
defaultValueSet or return the default value of the month field
disabledSets or returns whether the month field is available
formReturns a form reference using the month field
listReturns a datalist reference containing the month field
maxSets or returns the value of the max property of the month field
minSets or returns the value of the min property of the month field
nameSets or returns the value of the name attribute of the month field
readOnlySets or returns whether the month field is read-only
requiredSets or returns whether the month field is required in the form
stepSets or returns the value of the step property of the month field
typeReturns the form element type of the month field
valueSets or returns the value of the value attribute of the month field

Standard Properties and Events

Input Month objects also support standard properties and events .


Related articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML <input> Tag

HTML Reference Manual: HTML <input> type attribute