HTML DOM Input Date Object

Input Date object

The Input Date object is a new object in HTML5.

The Input Date object represents the HTML <input type="datetime"> element.

Note:Internet Explorer or Firefox does not support the <input type="date"> element.

Access the Input Date object

You can access the <input type="date"> element by using getElementById():

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

Try it yourself

Tip:You can also iterate over the form's elements collectionTo access the Input Date object.

Create an Input Date object

You can create an <input type="date"> element by using the document.createElement() method:

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

Try it yourself

Input Date object properties

Properties Description
autocomplete Set or return the autocomplete attribute value of the date field.
autofocus Set or return whether the date field should automatically focus after the page is loaded.
defaultValue Set or return the default value of the date field.
disabled Set or return whether the date field is disabled.
form Return a reference to the form containing the date field.
list Return a reference to the datalist containing the date field.
max Set or return the max attribute value of the date field.
min Set or return the min attribute value of the date field.
name Set or return the name attribute value of the date field.
readOnly Set or return whether the date field is read-only.
required Set or return whether the date field must be filled out before submitting the form.
step Set or return the step attribute value of the date field.
type Return the form element type of the date field.
value Set or return the value of the date field's value attribute.

Input Date object methods

Method Description
select() Select the content of the date text field.
stepDown() Decrement the value of the date field by a specified number.
stepUp() Increment the value of the date field by a specified number.

Standard attributes and events

Input Date object supports standardsPropertiesandEvents.

Related pages

HTML Tutorial:HTML Forms

HTML Reference Manual:HTML <input> tag

HTML Reference Manual:HTML <input> type attribute