<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");
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");
Input Date object attributes
Attribute | Description |
---|---|
autocomplete | Sets or returns the value of the autocomplete attribute of the date field |
autofocus | Sets or returns whether the date field automatically gets focus after page load |
defaultValue | Set or return the default value of the date field |
disabled | Set or return whether the date field is available |
form | Returns a form reference using a date field |
list | Returns a reference to the datalist containing the date field |
max | Sets or returns the max attribute value of a date field |
min | Sets or returns the value of the min property of a date field |
name | Sets or returns the value of the name attribute 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 value of the step attribute of a date field |
type | The form type that returns the date field |
value | Sets 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