HTML DOM Input Datetime Object | HTML Datetime Input Tutorial By WDH

HTML DOM Input Datetime Object


TML DOM Input Datetime object


Input Datetime object

 

Input Datetime objects are new to HTML5.

The Input Datetime object represents an HTML and input element that uses the type-"datetime" property.

Note: Internet Explorer, Firefox, Opera 15 (and later) or Chrome supports the use of type "datetime" for elements.

Access the Input Datetime object

You can use the getElementById() function to access the elements that use the type"datetime" property:

var x = document.getElementById("myDatetime"); Give it a try

Tip: You can also access the Input Datetime object through the form's collection of elements.

Create an Input Datetime object

You can use the document.createElement() method to create an element that uses the type"datetime" property:

var x = document.createElement("INPUT");
x.setAttribute("type", "datetime"); Give it a try

Input Datetime object properties

Property Describe
autocomplete Set or return the autocomplete property value of the datetime field
autofocus Set or return whether the datetime field automatically gets focus after the page loads
defaultValue Set or return the default value for the datetime field
disabled Set or return whether the datetime field is disabled
form Returns a form reference that uses the datetime field
list Returns a datalist reference that contains the datetime field
max Set or return the max property value of the datetime field
min Set or return the min property value of the datetime field
name Set or return the name property value of the datetime field
readOnly Set or return whether the datetime field is read-only
required Set or return whether the datetime field is required in the form
step Set or return the step property value of the datetime field
type Returns the type of form element for the datetime field
value Set or return the value property value of the datetime field