Skip to content

Instantly share code, notes, and snippets.

@grampelberg
Forked from hikahi/gist:49560
Created January 20, 2009 17:16
Show Gist options
  • Save grampelberg/49561 to your computer and use it in GitHub Desktop.
Save grampelberg/49561 to your computer and use it in GitHub Desktop.
function travelDates () {
dateArray = new Array();
for (i=0; i < document.getElementsByName("date").length; i++) {
dateArray[i] = new Date(document.getElementsByName("date")[i].value);
}
badDates = 0;
for (i=0; i < dateArray.length - 1; i++) {
if (dateArray[i] < dateArray[i+1]) {
alert ("good");
} else {
alert ("bad");
badDates = 1;
break;
}
}
if (badDates) {
errorFields[errorFields.length] = "badDates";
} else {
clearFields[clearFields.length] = "badDates";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment