Javascript DOM HTML Input Date stepDown() Method

Introduction

Decrement the value of a date field by 5 days:

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

Click the button to decrement 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() {//from w w w. j ava  2 s.c o m
  document.getElementById("myDate").stepDown(5);
}
</script>

</body>
</html>

The stepDown() method decrements the value of the date field by a specified number.

This method will only have an affect on days.

Parameter Values

Parameter Description
numberRequired. Set the amount of days the date field should decrease.

If omitted, the days are decremented by "1"

Decrement the days by 1 (default):

Click the button to decrement 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  va2s  . co  m
  document.getElementById("myDate").stepDown();
}
</script>

</body>
</html>



PreviousNext

Related