Sometime back i had asked question in SO as to how to validate startdate < enddate.
The JS that i had written is as below;
function DateValidation(startDate, endDate) {
if (startDate != ' ' && endDate != ' ')
{
var stdate = Date.parse(startDate);
var enddate = Date.parse(endDate);
if (stdate > enddate)
{
alert('Start date cannot be greater than end date!');
return false;
}
else
{
return true;
}
}
}
The function gets called on the click of the submit button. It is register as;
OnClientClick="javascript: return DateValidation(window.document.getElementById('txtStartDate').value,window.document.getElementById('txtEndDate').value);"
Now assume that start date is October 4 2011 (04/10/2011) and end date is December 2 2011 (02/12/2011). In this case the alert should NOT get fired but it still gets fired up (because 04 > 02).
What mistake am i making here?