HTML DOM Input Datetime Object


Input Datetime Object

The Input Datetime Object is new in HTML5.

The Input Datetime object represents an HTML <input> element with type="datetime".

Note:Internet Explorer, Firefox, Opera 15 (and higher), or Chrome support the <input> element with type="datetime".

Access the Input Datetime Object

You can use the getElementById() function to access the <input> element with type="datetime":

var x = document.getElementById("myDatetime"); Try it Yourself

Tip:You can also use the form'selementscollection to access the Input Datetime object.

Create an Input Datetime Object

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

var x = document.createElement("INPUT");
x.setAttribute("type", "datetime"); Try it Yourself

Input Datetime Object Properties

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

Standard Properties and Events

The Input Datetime object also supports standardpropertiesandevents。


Related Articles

HTML Tutorial:HTML Forms

HTML Reference Manual:HTML <input> Tag

HTML Reference Manual:HTML <input> type Attribute

Other Extensions