Input Month step Attribute

Definition and Usage

step Sets or returns the value of the step attribute of the month field.

The HTML step attribute specifies the legal month intervals that can be selected when the user opens the calendar in the month field.

For example, if step = "2", then only every other month can be selected from the calendar (such as January, March, May).

See also:

HTML Reference Manual:HTML <input> step Attribute

Example

Example 1

Change the legal month interval:

document.getElementById("myMonth").step = "2";

Try it yourself

Example 2

Get the legal month interval:

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

Try it yourself

Syntax

Return the step attribute:

monthObject.step

Set the step attribute:

monthObject.step = number

Attribute value

Value Description
number

Define the legal month interval. The default is 1 month.

Example:

  • If step="2", you can only select the calendar every month.
  • If step="5", you can only select the calendar every four months.

Technical Details

Return Value: A number representing the legal month interval.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported Not Supported Not Supported Supported Supported

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