Input Datetime autofocus attribute
Definition and usage
autofocus
Attribute sets or returns whether the date and time field should automatically receive focus on page load.
This property reflects the HTML autofocus attribute.
See also:
HTML Reference Manual:HTML <input> autofocus Attribute
Example
Find out if the date and time field automatically receives focus on page load:
var x = document.getElementById("myDatetime").autofocus;
Syntax
Return autofocus attribute:
datetimeObject.autofocus
Set autofocus attribute:
datetimeObject.autofocus = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specifies whether the date and time field should receive focus when the page is loaded.
|
Technical details
Return value: | Boolean value, if the date and time field automatically focuses on page load, it returns true , otherwise return false . |
---|
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Note:The <input type="datetime"> element does not display any date and time field/calendar in any mainstream browser except Safari.