Input Date autofocus Attribute
Definition and Usage
autofocus
Attribute setting or returning whether the date field should automatically gain focus when the page is loaded.
This property reflects the HTML autofocus attribute.
See also:
HTML Reference Manual:HTML <input> autofocus Attribute
Example
Find out if the date field automatically gains focus when the page is loaded:
var x = document.getElementById("myDate").autofocus;
Syntax
Return autofocus attribute:
inputdateObject.autofocus
Set autofocus attribute:
inputdateObject.autofocus = true|false
Attribute value
Value | Description |
---|---|
true|false |
Specify whether the date field should gain focus when the page is loaded.
|
Technical details
Return value: | Boolean value, returns if the date field automatically focuses on page load. true , otherwise return false . |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Note:The <input type="date"> element does not display any date field/calendar in IE11 and earlier versions.