HTML DOM Input Time Object

Input Time Object

The Input Time object represents the HTML <input> element with type="time".

Note:<input type="time"> does not display as a correct time field in IE11 and earlier versions.

Access Input Time Object

You can access the <input> element with type="time" using getElementById():

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

Try it yourself

Tip:You can also access the <input type="time"> by searching the elements collection of the search form.

Create an Input Time object

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

var x = document.createElement("INPUT");
x.setAttribute("type", "time");

Try it yourself

Input Time object attributes

Attributes Description
autocomplete Set or return the value of the time field's autocomplete attribute.
autofocus Set or return whether the time field should automatically focus when the page is loaded.
defaultValue Set or return the default value of the time field.
disabled Set or return whether the time field is disabled.
form Return a reference to the form containing the time field.
list Return a reference to the data list containing the time field.
max Set or return the value of the time field's max attribute.
min Set or return the value of the time field's min attribute.
name Set or return the value of the time field's name attribute.
readOnly Set or return whether the time field is read-only.
required Set or return whether the time field must be filled out before submitting the form.
step Set or return the value of the time field's step attribute.
type Return the type of form element the time field is.
value Set or return the value of the time field's value attribute.

Input Time object methods

Method Description
select() Select the content of the time text field.
stepDown() Decrease the value of the time field by a specified number.
stepUp() Increase the value of the time field by a specified number.

Standard attributes and events

The Input Time object supports both standard attributes and events.

Related pages

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML <input> tag

HTML Reference Manual: HTML <input> type attribute