Programming instructions
Developing code to validate data and enforce business rules 113
var testdate = new Date(dateString.substring(6,10),
dateString.substring(0,2)-1,
dateString.substring(3,5));
if (testdate > now) 
return true;
else
return false;
}
Another reason that rule 6 requires JavaScript scripting is that it tests the values of more 
than one field in a single edit. You must ensure that the return date field is greater than 
departure date field. To do this, you add a JavaScript function to validate the trip date 
range entered, and specify the function on the 
onValidate attribute of the returnDate 
cfinput tag.
function validateTripDateRange(oForm, oTag, dateString)
{
/*
parameters: oForm, oTag, dateString 
returns: boolean
oForm is the CFForm object. All onvalidate calls pass this argument. 
This function ignores it.
oTag is the CFForm current tag object. All onvalidate calls pass this argument.
This function ignores it.
dateString is the value of the current tag object. It should be a date 
passed as a string in the following
format: MM/DD/YYYY. This means that months and days require leading zeros!!
Returns true if the date passed is a future date greater than the departure date
Returns false if the date passed is NOT a future date greater than departure
date.
*/
//Edit to make sure that Return date is Later than departure date.
var returnDateString;
//First check to see if the departure Date is a valid future date
if (isitFutureDate(oForm, oTag, dateString) == false)
return false;
var departureDate = new Date(dateString.substring(6,10),
dateString.substring(0,2)-1,
dateString.substring(3,5));
returnDateString = document.forms(0).item("returnDate").value;
var returnDate = new Date(returnDateString.substring(6,10),
returnDateString.substring(0,2)-1,
returnDateString.substring(3,5));
if (departureDate < returnDate) 
return true;
else
return false;
}










