I am using Calender plugin to pick two dates respectively from & to. I need to compare value of to always greater than value of from using jQuery as soon as I pick the dates.
I am using the following code
var fromDate = $("#from").val();
var toDate = $("#to").val();
if (Date.parse(fromDate) > Date.parse(toDate)) {
alert("Invalid Date Range!\nStart Date cannot be after End Date!")
return false;
}
And the HTML code is:
<input type="text" name="from" id="from" value="" class="datepicker validate[custom[date]]" tabindex="4" />
<input type="text" name="from" id="from" value="" class="datepicker validate[custom[date]]" tabindex="4" />
If I use jquery validation plugin for comparision:
<input value="" class="validate[required,custom[date],future[2009-01-01]" type="text" id="d1" name="d1" />
As in http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/