Open In App

HTML | DOM Input Date stepUp() Method

Last Updated : 31 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The Input Date stepUp() method in HTML DOM is used to increment the value of date field by a specified number. The Input Date stepUp() method can only be used on the days and not on months and years. 

Syntax:

inputdateObject.stepUp( number )

Parameters: This method accepts single parameter number which is used to specify the amount of days the date field should increase. when we exclude number from inputdateObject.stepUp(number) and leave it as inputdateObject.stepUp() then by default number of days incremented by 1. 

Below program illustrates the Input Date stepUp method in HTML DOM: 

Example: This example use Input Date stepUp() method to increment the value of date field by 2 days. 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
HTML | DOM Input Date stepUp() Method
    </title>
</head>
 
<body style="text-align:center;">
 
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
     
    <h2 style="text-align:center;">
        Input Date stepUp Property
    </h2>
     
    <input type="date" id="Test_Date">
     
    <p>
        To increase the step, double click
        the "Increase Step" button.
    </p>
     
    <button ondblclick="My_Date()">
        Increase Step
    </button>
     
    <!-- Script to use Input Date stepUp() Method -->
    <script>
        function My_Date() {
            document.getElementById("Test_Date").stepUp(2);
        }
    </script>
</body>
 
</html>                   


Output: 

Before clicking on the button:

  

After clicking on the button:

  

Supported Browsers

  • Apple Safari 14.1
  • Edge 12
  • Firefox 57
  • Google Chrome 20
  • Opera 11


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads