for example, if you are using
MM/dd/yyyy
format
To compare two dates,First you will have to convert the
date string in to a Javascript
Date object
function getDateObj(dateString) {
var parts = dateString.split('/');
var month = parts[0];
var date = parts[1];
var year = parts[2];
return new Date(year, month, date);
}
var date1 = document.getElementById('txtStartDate').value;
var date2 = document.getElementById('txtEndDate').value;
var dateObjFrom = getDateObj(date1)
var dateObjTo = getDateObj(date1)
if (dateObjFrom > dateObjTo) {
alert('Date From is greater')
}