Input Month step Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Month

Description

The step property sets or gets the step attribute of a month field, which controls the legal month intervals to choose from when the user opens the calendar in the month field.

Set the step property with the following Values

Value Description
number Sets 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.

Return Value

A Number, representing the legal month intervals

The following code shows how to change the legal month intervals:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Month and year: <input type="month" id="myMonth" value="1997-11">

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//from w w w.  j  ava2  s .c om
    document.getElementById("myMonth").stepUp();
}
</script>

</body>
</html>

Related Tutorials