YouTip LogoYouTip

Dom Obj Month

HTML DOM Input Month Object

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 the <input> element with the type="month" attribute.

Accessing the 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

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

Creating 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

Property Description
autocomplete Sets or returns the autocomplete attribute value of the month field
autofocus Sets or returns whether the month field should automatically get focus when the page loads
defaultValue Sets or returns the default value of the month field
disabled Sets or returns whether the 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 the month field
min Sets or returns the min attribute value of the month field
name Sets or returns the name attribute value of the month field
readOnly Sets or returns whether the month field is read-only
required Sets or returns whether the month field must be filled out before submitting the form
step Sets or returns the step attribute value of the month field
type Returns the form element type of the month field
value Sets or returns the value attribute value of the month field

Standard Properties and Events

The Input Month object also supports standard properties and events.


Related Articles

HTML Tutorial: HTML Forms

HTML Reference: HTML <input> Tag

← Prop Month AutofocusDom Obj Input Image β†’