Skip to content

Instantly share code, notes, and snippets.

@grampelberg
Forked from hikahi/gist:49575
Created January 20, 2009 18:29
Show Gist options
  • Save grampelberg/49589 to your computer and use it in GitHub Desktop.
Save grampelberg/49589 to your computer and use it in GitHub Desktop.
function travelDates (elementName) {
dateArray = new Array();
for (i=0; i < document.getElementsByName(elementName).length; i++) {
dateArray[i] = new Date(document.getElementsByName(elementName)[i].value);
}
blankDates = 0;
for (i=0; i < document.getElementsByName(elementName).length; i++) {
if (document.getElementsByName(elementName)[i] == "MM/YY/YYYY" ||
document.getElementsByName(elementName)[i] == "") {
blankDates = 1;
break;
}
}
if (blankDates) {
ErrorFields[ErrorFields.length] = elementName + "s-blank";
return;
} else {
ClearFields[ClearFields.length] = elementName + "s-blank";
}
badDates = 0;
for (i=0; i < dateArray.length - 1; i++) {
if (dateArray[i] > dateArray[i+1]) {
badDates = 1;
break;
}
}
if (badDates) {
ErrorFields[ErrorFields.length] = elementName + "s-nomatch";
} else {
ClearFields[ClearFields.length] = elementName + "s-nomatch";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment