Latest web development tutorials
 

Input Month step Property

< Input Month Object

Example

Change the legal month intervals:

document.getElementById("myMonth").step = "2";
Try it Yourself »

Definition and Usage

The step property sets or returns the value of the step attribute of a month field.

The step attribute specifies the legal month intervals to choose from when the user opens the calendar in the month field.

For example, if step = "2", you can only select every second month in the calendar (like January, March, May).


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The step property is supported in all major browsers.

Note: The step property is not supported in Internet Explorer 9 and earlier versions.

Note: The <input type="month"> element is not supported in Internet Explorer or Firefox.


Syntax

Return the step property:

monthObject.step

Set the step property:

monthObject.step=number

Property Values

Value Description
number Specifies the legal month intervals. Default is 1 month.

Examples:

If step="2", you can only select every second month in the month calendar.

If step="5", you can only select every fifth month in the month calendar.

Technical Details

Return Value: A Number, representing the legal month intervals

More Examples

Example

Get the legal month intervals:

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

The result of x will be:

3
Try it Yourself »

Related Pages

HTML reference: HTML <input> step attribute


< Input Month Object