Input Month autofocus Attribute

Definition and Usage

autofocus Attribute sets or returns whether the month 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

Check if the month field will automatically activate focus when the page is loaded:

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

Try it yourself

Syntax

Return the autofocus attribute:

monthObject.autofocus

Set the autofocus attribute:

monthObject.autofocus = true|false

Attribute value

Value Description
true|false

Specifies whether the month field should gain focus when the page is loaded.

  • true - The month field has gained focus
  • false - Default. The month field has not gained focus

Technical Details

Return value: Boolean value, returned if the month field automatically gains focus when the page is loaded true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="month"> element does not display any date field/calendar in Firefox.