Input Month max Attribute

Definition and Usage

max attribute to set or return the value of the max attribute of the month field.

HTML max attribute specifies the maximum value for the month field (month and year).

Tip:Use the max attribute and min attributes to create a series of valid values.

Tip:To set or return the value of the min attribute, use min attribute.

See also:

HTML Reference Manual:HTML <input> max Attribute

Example

Example 1

Get the maximum allowed month and year for the month field:

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

Try It Yourself

Example 2

Change the maximum month and year:

document.getElementById("myMonth").max = "2023-06";

Try It Yourself

Syntax

Return max attribute:

monthObject.max

Set max attribute:

monthObject.max = YYYY-MM

Attribute Value

Value Description
YYYY-MM

The maximum allowed month and year.

Component Description:

  • YYYY - Year (e.g., 2023)
  • MM - Month (e.g., 06 for June)

Technical Details

Return Value: A string value representing the maximum month and year allowed.

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.