Code:
///////////////////////////////////////
// CHILD Birthday Checker //
///////////////////////////////////////
// DESCRIPTION: //
// CHECK IF THE DECLARED CHILD DOB //
// IS LESS THAN 12 YEARS OLD //
///////////////////////////////////////
function checkChdBirthday(obj)
{
df = document.form;
retdate = df.retdt.value; // Return Date of Journey in YYYYMMDD format
if(document.form.nochd.value==1)
{
nochdvalue=document.form.nochd.value
}
else
{
nochdvalue=document.form.nochd.value-1
}
for (i=0; i<nochdvalue; i++) // loop through the number of children
{
number=number+1;
if( !/^(\d{1,2})(\d{1,2})(\d{4})$/.test(obj.value) )
{
alert( "Invalid date supplied - must be format DDMMYYYY" );
return;
}
// pass Infant DOB to check_date to check for invalid dates
// e.g. 30022002
check_date(obj);
var d = new Date();
var d2 = new Date(RegExp.$3, RegExp.$2, RegExp.$1);
nochd = document.form.nochd.value
noinf = document.form.noinf.value
var diff = d.getDiff(d2, "y")
if( isNaN(diff) )
{
alert( "Invalid date supplied" );
}
else if( diff < 12 ) {
//alert( "This IS an CHILD \n they are younger than 12" );
child = true;
submit_form=true;
under12counter = under12counter + 1;
passtocheckRetDate = obj.value;
checkRetDate(document.form.retdt);
}
else if( diff > 12 ) {
//alert( "This is NOT an CHILD\nthey are older than 12" );
child = false;
submit_form=false;
chdcounter = chdcounter + 1; // amount of declared children that are found to be under 12
childno = i+1
forename = document.form.cfname1.value
surname = document.form.clname1.value
if(chdcounter==2)
{
if(document.form.cfname2.value!="")
{
forename2 = document.form.cfname2.value
surname2 = document.form.clname2.value
}
}
if(chdcounter==3)
{
if(document.form.cfname3.value!="")
{
forename3 = document.form.cfname3.value
surname3 = document.form.clname3.value
}
}
}
}
inf_ok=false;
}
is there a way to change the above code to take into consideration
the date and the month when finding the difference in the two dates.
Something in the RegExp function?
www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt