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:Atributo autofocus del <input> en HTML

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 receives focus
  • false - Default. The local date and time field does 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; de lo contrario, devuelve false.

Compatibilidad del navegador

Los números en la tabla indican la versión del navegador que primero admite completamente esta propiedad.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Compatibilidad 10.0 Compatibilidad Compatibilidad Compatibilidad

Atención:El elemento <input type="datetime-local"> no muestra ningún campo de fecha y hora ni calendario en Firefox.