Javascript DOM HTML Input Date stepUp() Method

Introduction

Increment the value of a date field by 5 days:

document.getElementById("myDate").stepUp(5);

Click the button to increment the value of the date field by 5 days.

View in separate window

<!DOCTYPE html>
<html>
<body>

Date: <input type="date" id="myDate" value="2014-05-05">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {// www.  ja  v  a 2s .  c o  m
  document.getElementById("myDate").stepUp(5);
}
</script>

</body>
</html>

The stepUp() method increments the value of the date field by a specified number.

This method will only have an affect on days.

Parameter Values

Parameter Description
numberRequired. Specifies the amount of days the date field should increase.

If omitted, the days are incremented by "1"

Increment the days by 1 (default):

Click the button to increment the value of the date field by 1 day.

View in separate window

<!DOCTYPE html>
<html>
<body>

Date: <input type="date" id="myDate" value="2014-05-05">
<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//from  ww  w. ja va  2s  .c om
  document.getElementById("myDate").stepUp();
}
</script>

</body>
</html>



PreviousNext

Related