Input Datetime autofocus Attribute

Definition and Usage

autofocus Attribute sets or returns whether the date-time field should automatically receive focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See also:

HTML Reference Manual:Propriedade autofocus do <input> no HTML

Example

Find out if the date-time field automatically receives focus when the page is loaded:

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

Try it yourself

Syntax

Return autofocus attribute:

datetimeObject.autofocus

Set autofocus attribute:

datetimeObject.autofocus = true|false

Attribute value

Value Description
true|false

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

  • true - The date-time field receives focus
  • false - Default. The date-time field does not receive focus

Technical details

Return value: Boolean value, if the date-time field automatically focuses when the page is loaded, it returns truede outra forma, retorna false.

Suporte do navegador

Os números na tabela indicam a versão do navegador que suporta completamente essa propriedade.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Suporte 10.0 Suporte Suporte Suporte

Atenção:O elemento <input type="datetime"> não exibe nenhum campo de data e hora / calendário em navegadores principais, exceto Safari.