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

HTML DOM Input Datetime Object

HTML DOM Input Datetime Object


Input Datetime Object

The Input Datetime object is new in HTML5.

The Input Datetime object represents an HTML element with a type="datetime" attribute. .

Note: Supported by Internet Explorer, Firefox, Opera 15 (and later), or Chrome. element using type="datetime".

Accessing the Input Datetime Object

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

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

Try it

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

Creating the Input Datetime Object

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

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

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

Try it

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 gets 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 using the datetime field.
list Returns a reference to the datalist containing 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 required 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 of the datetime field.

Standard properties and events

The Input Datetime object also supports standard property and Events.


Related Articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML tag

HTML Reference Manual: HTML type Attribute