Input DatetimeLocal autofocus attribute

Definition and usage

autofocus Attribute settings or returns whether the local date and time field should be automatically focused when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:HTML <input> autofocus Attribute

Example

Determine whether the local date and time field is automatically focused when the page is loaded:

var x = document.getElementById("myLocalDate").autofocus;

Try it yourself

Syntax

Return autofocus attribute:

datetimelocalObject.autofocus

Set autofocus attribute:

datetimelocalObject.autofocus = true|false

Attribute value

Value Description
true|false

Specify whether the local date and time field should receive focus when the page is loaded.

  • true - The local date and time field received focus
  • false - Default. The local date and time field did not receive focus

Technical details

Return value: Boolean value, if the local date and time field is automatically focused when the page is loaded, it returns 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="datetime-local"> element does not display any date and time fields/calendar in Firefox.