I have the following :
var fit_start_time = $(\"#fit_start_time\").val(); //2013-09-5
var fit_end_time = $(\"#fit_end_time\").val(); //2013-09-10
if(Da
As in your example, the fit_start_time
is not later than the fit_end_time
.
Try it the other way round:
var fit_start_time = $("#fit_start_time").val(); //2013-09-5
var fit_end_time = $("#fit_end_time").val(); //2013-09-10
if(Date.parse(fit_start_time) <= Date.parse(fit_end_time)){
alert("Please select a different End Date.");
}
Update
Your code implies that you want to see the alert
with the current variables you have. If this is the case then the above code is correct. If you're intention (as per the implication of the alert message
) is to make sure their fit_start_time
variable is a date that is before the fit_end_time
, then your original code is fine, but the data you're getting from the jQuery .val()
methods is not parsing correctly. It would help if you gave us the actual HTML which the selector is sniffing at.