Compare two dates in JavaScript and JQuery

Compare two dates in JavaScript and JQuery


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” />


Create a Button and Call the function CompareDate();

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

Step 3:

Write Following JavaScript Function To Compare


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

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

if( fdate== todate)


alert(“Values Are Same”);




alert(“Values are not same”);





Click to comment

Leave a Reply

Your email address will not be published.

Most Popular

To Top
%d bloggers like this: