Input Date step Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Date

Description

The step property sets or gets the step attribute of a date field, which control the day intervals to choose from.

Set the step property with the following Values

Value Description
number Sets the legal day intervals. Default is 1 day.

Examples:

  • If step="2", you can only select every second day in the date calendar.
  • If step="10", you can only select every tenth day in the date calendar.

Return Value

A Number, representing the legal day intervals

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Date: <input type="date" id="myDate" value="2018-05-05">

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

<script>
function myFunction() {/*from  ww w.  j a v  a2  s. c o  m*/
    document.getElementById("myDate").stepUp();
}
</script>

</body>
</html>

Related Tutorials