<input> - date


HTML DOM Input Date object


Input Date object

The Input Date object is new in HTML5.

Input Date objects represent HTML <input> elements with the type="date" attribute.

Note: IE11 and earlier versions do not support <input> elements with the type="date" attribute.

Access the Input Date object

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

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

 Try It! 

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

Create an Input Date object

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

var x = document.createElement("INPUT");
x.setAttribute("type", "date");

Try It! 

Input Date object attributes

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

Standard Properties and Events

Input Date 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