<input> - datetime
HTML DOM Input Datetime object
Input Datetime object
The Input Datetime object is new in HTML5.
Input Datetime objects represent HTML <input> elements using the type="datetime" attribute.
Note: Internet Explorer, Firefox, Opera 15 (and later) or Chrome support <input> elements with type="datetime".
Access the Input Datetime object
You can use the getElementById() function to access <input> elements with the type="datetime" attribute:
var x = document.getElementById("myDatetime");
Tip: You can also access the Input Datetime object through the form's elements collection.
Create an Input Datetime object
You can use the document.createElement() method to create an <input> element with the type="datetime" attribute:
var x = document.createElement("INPUT");
x.setAttribute("type", "datetime");
Input Datetime Object Attributes
Attribute | Description |
---|---|
autocomplete | Sets or returns the value of the autocomplete attribute of the datetime field |
autofocus | Sets or returns whether the datetime field automatically gets focus after page load |
defaultValue | Set or return the default value of the datetime field |
disabled | Sets or returns whether the datetime field is disabled |
form | Returns a form reference using a datetime field |
list | Returns a datalist reference containing datetime fields |
max | Sets or returns the value of the max attribute of a datetime field |
min | Sets or returns the value of the min attribute of a datetime field |
name | Sets or returns the value of the name attribute of a datetime field |
readOnly | Sets or returns whether the datetime field is read-only |
required | Sets or returns whether the datetime field is required in the form |
step | Sets or returns the value of the step attribute of a datetime field |
type | Returns the form element type of the datetime field |
value | Sets or returns the value of the datetime field's value attribute |
Standard Properties and Events
Input Datetime 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