Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Date Object

HTML DOM Input Date Object


Input Date Object

The Input Date object is new in HTML5.

The Input Date object represents an HTML element with a type="date" attribute. element.

**Note:** IE11 and earlier versions do not support the element with a type="date" attribute. .

Accessing the Input Date Object

You can use the getElementById() function to access an element with a type="date" attribute. element:

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

Try it

Tip: You can also access the Input Color object through a form'sElementcollection to access the Input Date object.

Creating the Input Date Object

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

var x = document.createElement("INPUT");

x.setAttribute("type", "date");

Try it

Input Date Object Properties

Property Description
autocomplete Sets or returns the autocomplete attribute value of the date field.
autofocus Sets or returns whether the date field automatically gets focus after the page loads.
defaultValue Sets or returns the default value of the date field.
disabled Sets or returns whether the date field is enabled.
form Returns a reference to the form using the date field.
list Returns a reference to the datalist containing the date field.
max Sets or returns the max attribute value of the date field.
min Sets or returns the min attribute value of the date field.
name Sets or returns the name attribute value of the date field.
readOnly Sets or returns whether the date field is read-only.
required Sets or returns whether the date field is required in the form.
step Sets or returns the step attribute value of the date field.
type Returns the form type of the date field.
value Sets or returns the value attribute of the date field.

Standard properties and events

The Input Date object also supports standard property and Events.


Related Articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML tag

HTML Reference Manual: HTML type Attribute