Column

Compare two dates in JavaScript and JQuery

Compare two dates in JavaScript and JQuery

Step1:

To Compare Two Dates in Javascript and Jquery Create two date fields

<input type=”date” id=”FromDate” required class=”form-control” />

<input type=”date” id=”ToDate” required class=”form-control” />

Step2:

Create a Button and Call the function CompareDate();

<button onclick=”CompareDate()“>Compare</button>

Step 3:

Write Following JavaScript Function To Compare

<script>

var fdate=new Date($(“#FromDate”).val());

var todate=new Date($(“#Todate”).val());

if( fdate== todate)

{

alert(“Values Are Same”);

}

else

{

alert(“Values are not same”);

}

 

</script>

 

Click to comment

Leave a Reply

Your email address will not be published.

Most Popular

To Top
%d bloggers like this: