YouTip LogoYouTip

Dom Obj Datetime

HTML DOM Input Datetime Object

HTML DOM Input Datetime Object

-- Learning not just technology, but dreams!

JavaScript Reference

Overview

JavaScript Objects

Browser Objects

DOM Objects

HTML Objects

<input> - date

<input> - datetime-local

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 later), or Chrome support the <input> element with type="datetime".

Accessing an Input Datetime Object

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

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

Try it yourself

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

Creating 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 should automatically get focus when 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 that contains 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 must be filled out before submitting a 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 standard properties and events.


Related Articles

HTML Tutorial: HTML Forms

← Prop Datetime AutofocusProp Date Value β†’