HTML DOM Input DatetimeLocal Object


Input DatetimeLocal Object

The Input DatetimeLocal object is new in HTML5.

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

Note:Internet Explorer or Firefox browsers do not support the <input> element.

Access an Input DatetimeLocal Object

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

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

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

Create an Input DatetimeLocal Object

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

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

Input DatetimeLocal Object Properties

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

Standard Properties and Events

The Input DatetimeLocal 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