Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 20th, 2005, 06:39 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default drop-down menu validation

I have a problem with the following code. I run a onChange when the drop-down is change. Basically,
it is validation to check for the date of births for a child.

The appropriate alert is shown as to what condition is met (this is not a problem).

But if the user does not change the DOB THEN clicks the 'CONFIRM' button, it passes to the next
page without re-checking the DOB drop-downs.

Heres my code:

ASP/HTML:

Code:
<select name="chddate<%=j%>"
onChange="document.form.chdbirthday<%=j%>.value=document.form.chddate<%=j%>.options[document.form.chddate<%=j%>.selectedIndex].value+document.form.chdmonth<%=j%>.options[document.form.chdmonth<%=j%>.selectedIndex].value+document.form.chdyear<%=j%>.options[document.form.chdyear<%=j%>.selectedIndex].value;
javascript: checkChdBirthday(document.form.chdbirthday<%=j%>); chdinf(); confirm(); confirmedok();"
style="color: black; font: 7pt Verdana, Arial, Helvetica, sans-serif;"> 
        <%
        Response.write "<option> --- </option>"
For d = 1 to 31
    if len(d) = 1 then
        Response.Write "<option value=0"& d & ">" & d & "</option>"
    else
        Response.write "<option value=" & d & ">" & d & "</option>"
    end if
Next
%> 
</select> 
<select name="chdmonth<%=j%>"
onChange="document.form.chdbirthday<%=j%>.value=document.form.chddate<%=j%>.options[document.form.chddate<%=j%>.selectedIndex].value+document.form.chdmonth<%=j%>.options[document.form.chdmonth<%=j%>.selectedIndex].value+document.form.chdyear<%=j%>.options[document.form.chdyear<%=j%>.selectedIndex].value;
javascript: checkChdBirthday(document.form.chdbirthday<%=j%>); chdinf(); confirm(); confirmedok();"
style="color: black; font: 7pt Verdana, Arial, Helvetica, sans-serif;" > 
      <%
    Response.write "<option> --- </option>"
For m = 1 to 12
    if len(m) = 1 then
        Response.write "<option value=0"& m & ">" & MMtoMMM(m) & "</option>"
    else
        Response.Write "<option value=" & m & ">" & MMtoMMM(m) & "</option>"
    end if
Next
%> 
      </select> 
      <% 
Dim vor_15_jahren 
vor_15_jahren = year(date) - 15
%> 
<select name="chdyear<%=j%>"
onChange="document.form.chdbirthday<%=j%>.value=document.form.chddate<%=j%>.options[document.form.chddate<%=j%>.selectedIndex].value+document.form.chdmonth<%=j%>.options[document.form.chdmonth<%=j%>.selectedIndex].value+document.form.chdyear<%=j%>.options[document.form.chdyear<%=j%>.selectedIndex].value;
javascript: checkChdBirthday(document.form.chdbirthday<%=j%>); chdinf(); confirm(); confirmedok();"
style="color: black; font: 7pt Verdana, Arial, Helvetica, sans-serif;">
<%
    Response.write "<option> --- </option>"
For y = vor_15_jahren to year(date) -2
    Response.Write "<option value=" & y & ">" & y & "</option>"
Next
%> 
                </select> 

                <input type="hidden" name="chdbirthday<%=j%>" size="5" style="font:7pt;" maxLength="10">
JavaScript:

[code]
<script language="javascript">
// Last Edit: CRM_14jul05
/////////////////////////////////////////////
// DESCRIPTION: //
// JAVASCRIPT VALIDATION FOR THE DROP DOWN //
// DATE OF BIRTH MENUS FOR CHILD AND INF //
/////////////////////////////////////////////
// Max CHD: 8 (EIGHT) (1 ADT & 8 CHD) //
// Max INF: 4 (FOUR) (4 ADT & 4 INF) //
/////////////////////////////////////////////
function refresh()
{
    window.location.reload(false);
}

// Function to change any text to Proper Case (e.g. picco -> Picco)
String.prototype.toProperCase = function()
{
    return this.charAt(0).toUpperCase() + this.substring(1,this.length).toLowerCase();
}

// Set inital counter values to zero
chdcounter = 0;
infcounter = 0;
under12counter = 0;
under2counter = 0;
number=0;
kostenzahler=0;

// Set inital values to false/true
child=false;
infant=false;
chdredirect=false;
infredirect=false;
infalerted=false;
bad_date=false;
submit_form=false;
check_chd_invalid_chars=false;
check_inf_invalid_chars=false;
do_not_alert=false;
do_not_check_full_dob=false;
check_full_dob=false;
CHD_do_not_check_full_dob=false;
CHD_check_full_dob=false;
chd_invdate="false";
inf_invdate="false";


// Set inital values to yes/no
confirm_redirect="no";
img_unclicked="no";

// declare variables
var inf_age;
var duplikat_chd;
var chdalerted;
var gehen_Sie;
var empty_field;

function confirm()
{
    //alert("function - confirm");
    img_unclicked="true"; // set variable to state that the 'CONFIRM' image has NOT been clicked
    //alert("img_unclicked = " + img_unclicked);
}

function confirm_img()
{
    //alert("function - confirm_img");
    img_unclicked="false";
    gehen_Sie=true;
}
///////////////////////////////////////
// Date of Birth Validation //
// Check if Infant < 2 Jahre Alt //
// Check if Child < 12 Jahre Alt //
///////////////////////////////////////

Date.prototype.getDiff = function(date, interval){
  if (typeof date == "string"){
     date = new Date(date);
  }
  if (isNaN(date) || !(date instanceof Date)){
     return NaN;
  }
  if (typeof interval == "undefined") interval = "ms";
  var diff = this - date;
  switch(interval.toLowerCase()){
    case "s":
        diff = diff/1000; break;
    case "n":
        diff = diff/(1000*60); break;
       case "h":
        diff = diff/(1000*60*60); break;
       case "d":
        diff = diff/(1000*60*60*24); break;
    case "m":
        diff = diff/(1000*60*60*24*30); break;
    case "y":
        diff = diff/(1000*60*60*24*365); break;
    default:
      ;
  }
  return Math.floor(diff);
}



///////////////////////////////////////
// CHILD Birthday Checker //
///////////////////////////////////////
// DESCRIPTION: //
// CHECK IF THE DECLARED CHILD DOB //
// IS LESS THAN 12 YEARS OLD //
///////////////////////////////////////
function checkChdBirthday(obj)
    {
    alert("function = checkChdBirthday");
    alert("chdbirthday value = " + obj.value);

    var today_date = new Date();
    var today_d = today_date.getDate();
    var today_day = (today_d < 10) ? '0' + today_d : today_d;
    var today_m = today_date.getMonth() + 1;
    var today_month = (today_m < 10) ? '0' + today_m : today_m;
    var today_yy = today_date.getYear();
    var today_year = (today_yy < 1000) ? today_yy + 1900 : today_yy;
    var today;
    today = today_year + today_month + today_day
    alert("today = " + today);

    objvalue_yyyy = obj.value.slice(4,8) // YYYY (2004)
    objvalue_mm = obj.value.slice(2,4) // MM (02)
    objvalue_dd = obj.value.slice(0,2) // DD (27)

    var objvalue;
    objvalue=objvalue_yyyy+objvalue_mm+objvalue_dd;
    alert("objvalue = " + objvalue);

    the_difference = today - objvalue

    if(the_difference > 120000)
    {
            add=add+1;
            alert("You have entered an incorrect Date of Birth for the Children\nChild must be aged 2-12 years old");
    }
    else
    {

    }
    //alert("CHD_CheckIT! = " + chd_checkit);
    //alert("chdalerted = " + chdalerted);

    if(chd_checkit==true)
    {
        nochd = document.form.nochd.value

        for(x=1;x<nochd;x++)
        {

            chd_length = eval("document.form.chdbirthday"+x+".value.length" )

            if((Math.ceil(chd_length)<8)&&(Math.round(chd_leng th)!=0))
            {
                CHD_do_not_check_full_dob=true; // CHD DOB has INCORRECT value (not DDMMYYYY)
            }
            if(Math.ceil(chd_length)==8)
            {
                CHD_do_not_check_full_dob=false; // CHD DOB is in correct format
            }

        }

    }

    //alert("CHD_do_not_check_full_dob = " + CHD_do_not_check_full_dob);
    if(CHD_do_not_check_full_dob==false) // if the length of the 'chdbirthday' field is 8 ('DDMMYYYY')
    {

    //alert("249");
    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
    }

    //alert("!LINE 261!");
    for (i=0; i<nochdvalue; i++) // loop through the number of children
    {
    nochdvalue=0;
    number=number+1;
    if( !/^(\d{1,2})(\d{1,2})(\d{4})$/.test(obj.value) )
    {
        if((do_not_alert!=true)&&(obj.value.length>=8))
        {
            alert( "Invalid date supplied - must be format DDMMYYYY" );
            //alert("obj.value = " + obj.value);
            chd_invdate="true";
            do_not_alert=true;
        }
        document.form.chddate1.focus();
        return;
    }
    else
    {
        chd_invdate="false";
    }

    //alert("282");
    // pass Infant DOB to check_date to check for invalid dates
    // e.g. 30022002
    check_chd_invalid_chars=true;

    check_date(obj);

    var date = new Date();
    var d = date.getDate();
    var day = (d < 10) ? '0' + d : d;
    var m = date.getMonth() + 1;
    var month = (m < 10) ? '0' + m : m;
    var yy = date.getYear();
    var year = (yy < 1000) ? yy + 1900 : yy;

    todayyyyymmdd = year + month + day // todays date in YYYYMMDD format

    yyyy = obj.value.slice(4,8) // YYYY (2004)
    mm = obj.value.slice(2,4) // MM (02)
    dd = obj.value.slice(0,2) // DD (27)

    dob = yyyy + mm + dd
    unterschied = todayyyyymmdd - dob

    nochd = document.form.nochd.value
    noinf = document.form.noinf.value

    //alert("bad_date = " + bad_date);
    if(bad_date!=true)
    {
        //alert("unterschied = " + unterschied);
        if(unterschied > 120000 ) // if the difference is more than 120,000 then NOT A CHILD
        {
            chd_invdate="false";
            bad_date=false;
            child = false;
            submit_form=false;
            chdcounter = chdcounter + 1; // amount of declared children that are found to be over 12
            childno = i+1
            kostenzahler=kostenzahler+1;
            alert("kostenzahler = " + kostenzahler);

            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
                }
            }

        }
        else if(unterschied < 120000) // if the difference is less than 120,000 then IS A CHILD
        {
            chd_invdate="false";
            bad_date=false;
            child=true;
            submit_form=true;
            chdcounter=0;
            under12counter = under12counter + 1;
            passtocheckRetDate = obj.value;
            checkRetDate(document.form.retdt);
        }
    }

    var d = new Date();
    var d2 = new Date(RegExp.$3, RegExp.$2, RegExp.$1);

    var diff = d.getDiff(d2, "y")
    if( isNaN(diff) )
    {
        alert( "Invalid date supplied" );
    }
    }
    inf_ok=false;

    }

    } // end of main if

////////////////////////////////////////
// VALIDATE DATE OF BIRTH FIELD //
////////////////////////////////////////
// DESCRIPTION: //
// CHECK THE DATE OF BIRTH FIELD FOR //
// INVALID DATES E.G. 30-FEBRUARY-2001//
////////////////////////////////////////
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++)
   {
      if (checkstr.indexOf(DateValue.substr(i,1)) >= 0)
      {
         DateTemp = DateTemp + DateValue.substr(i,1);
      }
   }
   bad_date=false;
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + month + year;
   }
   /* Error-message if err != 0 */
   else
   {
      bad_date=true;
      if((chd_invdate!="true")&&(inf_invdate!="true"))
      {
          alert("The Date you have entered is invalid\nPlease Re-enter");
        infcounter=0;
        chdcounter=0;
      }
      if(check_chd_invalid_chars==true)
      {
          document.form.chddate1.focus();
      }
      else if(check_inf_invalid_chars==true)
      {
        document.form.date1.focus();
      }
      submit_form=false;
   }
}

/////////////////////////////////////////////////
// CHD: CHECK THE RETURN DATE OF THE JOURNEY //
// AGAINST THE DATE OF BIRTH OF THE PASSENGER //
/////////////////////////////////////////////////
// DESCRIPTION: //
// TO DETERMINE IF THE PASSENGER CHANGES AGE //
// DURING THE JOURNEY //
/////////////////////////////////////////////////
function checkRetDate(obj)
    {
        //alert("function = checkRetDate");
        yyyy = passtocheckRetDate.slice(4,8) // YYYY (2004)
        mm = passtocheckRetDate.slice(2,4) // MM (02)
        dd = passtocheckRetDate.slice(0,2) // DD (27)

        yyyymmdd = yyyy + mm + dd; // YYYYMMDD (20040227)

        retdtminusdob = eval(obj.value-yyyymmdd) // difference between the return date and the INF date of birth

        if(nochd!=0)
        {
            if(retdtminusdob > 120000) // 120,071 // 120,000
            {
                alert("A Child will turn 12 during this journey\nThis passenger must be classed as an Adult and not a Child");
                document.form.chddate1.focus();
                chdredirect=true;
                submit_form=false;
            }
        }
    }




// WHEN THERE IS JUST AN ADULT TRAVELLING
function adt()
{
    adult = "yes"
}

function chdinf()
{
    //alert("function chdinf");
    adult = "no"
}
/////////////////////////////////////////////
// SUBMIT THE FORM //
/////////////////////////////////////////////
// DESCRIPTION: //
// DECIDE WHETHER TO PERFORM EXTRA FORM //
// FIELD CHECKS OR TO FLAG AN ALERT AS TO //
// WHAT CHD/INF HAS INCORRECT DOB ENTERED //
/////////////////////////////////////////////


function confirmedok()
{
    //alert("function CONFIRMEDOK");
    //alert("adult = " + adult);
    //alert("chd_count = " + chd_count);
    //alert("EMPTY FIELD = " + empty_field);
    //alert("submit_form = " + submit_form);

    if((gehen_Sie==true)&&(empty_field!=true)&&(chd_co unt==0)&&(inf_count==0))
    {
        check(document.form);
    }

    if(adult=="yes")
    {
        document.form.TK.value=document.form.TK.value;

        if((img_unclicked!="yes")&&(empty_field!=true)&&(c hd_count==0)&&(inf_count==0))
        {
            //alert("Check the form fields");
            check(document.form);
        }
    }

    if(adult!="yes")
    {
    //alert("ADULT = NO");
    //alert("chdcounter = " + chdcounter);
    //alert("infcounter = " + infcounter);
    //alert("chdredirect = " + chdredirect);
    //alert("infredirect = " + infredirect);
    //alert("bad_date = " + bad_date);
    // if there are no incorrectly entered DOBs then
    // proceed with additional validation on form fields
    if ((chdcounter==0)&&(infcounter==0)&&(chdredirect!=t rue)&&(infredirect!=true)&&(bad_date!=true))
    {
        //alert("submit_form = " + submit_form);

        // Proceed to perform additional checks on the form fields
        // no DATE OF BIRTH alerts will be shown
        if (submit_form==true)
        {
            //alert("inf_invdate = " + inf_invdate);
            //alert("chd_invdate = " + chd_invdate);
            //alert("empty_field = " + empty_field);
            //alert("chd_count = " + chd_count);
            //alert("inf_count = " + inf_count);


            if((inf_invdate!="true")&&(chd_invdate!="true")&&( empty_field!=true)&&(chd_count==0)&&(inf_count==0) )
            {
                document.form.TK.value=document.form.TK.value;
                check(document.form);
            }
        }
        else
        {
            nochd = document.form.nochd.value
            noinf = document.form.noinf.value
            if(nochd!=0)
            {
                if(child==false)
                {
                    do_not_submit_form=true;
                }
            }

            if(noinf!=0)
            {
                if(infant==false)
                {
                    do_not_submit_form=true;
                }
            }
        }

    }
    else if(bad_date!=true)
    {
        df = document.form
        nochd = df.nochd.value
        noinf = df.noinf.value

        ttlchd = nochd
        ttlinf = noinf

        allinfants=false;
        allkinder=false;
        allinfchd=false;

///////////////////////////////
// ALERT WARNINGS TO USER //
///////////////////////////////
// ALERT WHICH DOB IS //
// INVALID THEN REDIRECT TO //
// AIRBOOK FLIGHT SEARCH //
///////////////////////////////

//alert("INSIDE the ALERTS");
//alert("chdalerted = " + chdalerted);
//alert("duplikat_chd " + duplikat_chd);
//alert("INCORRECT chdcounter = " + chdcounter);
//alert("INCORRECT infcounter = " + infcounter);

        // IF THE CHILD & INFANT ARE BOTH TURNING 12 AND 2 THEN REDIRECT TO AIRBOOK TO DECLARE CHILD AS ADULT AND INFANT AS CHILD
        if((chdredirect==true)&&(infredirect==true))
        {
            confirm_redirect="yes";
        }

        // IF THE CHILD IS GOING TO TURN 12 DURING THE JOURNEY THEN REDIRECT TO AIRBOOK TO DECLARE CHILD AS ADULT
        if((chdredirect==true)&&(infredirect!=true))
        {
            confirm_redirect="yes";
        }

        // IF THE INFANT IS GOING TO TURN 2 DURING THE JOURNEY THEN REDIRECT TO AIRBOOK TO DELCARE INFANT AS CHILD
        if((infredirect==true)&&(chdredirect!=true))
        {
            confirm_redirect="yes";
        }

        // IF ALL THE INFANTS AND ALL THE CHILDREN HAVE INCORRECTLY ENTERED DOB
        if((Math.abs(infcounter)==Math.abs(ttlinf))&&(Math .abs(chdcounter)==Math.abs(ttlchd))&&(Math.abs(ttl chd>1)&&Math.abs(ttlinf>1))) //(duplikat_chd!=true)
        {
            //alert("743");
            allinfchd=true;
            chdalerted=true;
            infalerted=true;
            if(parseInt(unterschied)>120000)
            {
                alert("You have entered an incorrect Date of Birth for ALL Children\nA Child is classed as being aged between 2-12 (not inc.)\n\n" +
                "You have entered an incorrect Date of Birth for ALL Infants\nA Infant is classed as being aged between 0-2 (not inc.)");
            }
            else if(parseInt(unterschied)<120000)
            {
                chdcounter=0;
                submit_form=true;
            }
            all=true;
        }
        else
        {
            all=false;
            allinfchd=false;
        }

        // IF ALL THE CHILDREN HAVE INCORRECTLY ENTERED DOB
        if(Math.ceil(chdcounter)==Math.ceil(ttlchd)&&(Math .ceil(ttlchd!=0))&&(Math.ceil(ttlchd!=1))) //&&(duplikat_chd!=true)
        {
            if(allinfchd!=true)
            {
                allkinder=true;
                if(Math.floor(unterschied)>120000)
                {
                    alert("You have entered an incorrect Date of Birth for ALL Children\n"+
                          "A Child is classed as being aged between 2-12 (not inc.)");
                }
                else if(Math.abs(unterschied)<120000)
                {
                    chdcounter=0;
                    submit_form=true;
                }
                document.form.chddate1.focus();
                //alert("LINE number - 765");
                chdalerted=true;
                confirm_redirect="yes";
            }

        }
        else
        {
            allkinder=false;
        }


        // IF ALL THE INFANTS HAVE INCORRECTLY ENTERED DOB
        if((Math.abs(infcounter)==Math.abs(ttlinf))&&(Math .ceil(ttlinf!=0))&&(Math.ceil(ttlinf!=1)))
        {
            if(allinfchd!=true)
            {
                allinfants=true;
                if(Math.floor(inf_unterschied)>20000)
                {
                    alert("You have entered an incorrect Date of Birth for ALL Infants\n"+
                      "A Infant is classed as being aged between 0-2 (not inc.)");
                }
                else if(Math.floor(inf_unterschied)<20000)
                {
                    infcounter=0;
                    submit_form=true;
                }
                document.form.date1.focus();
                infalerted=true;
                confirm_redirect="yes";
            }
            else
            {
            infalerted=false;
            }
        }

        // BOTH: IF THERE ARE 1 OR MORE CHILDREN AND 1 OR MORE INFANTS WITH INCORRECT DOB
        if((Math.floor(chdcounter)!=0)&&(Math.floor(infcou nter)!=0))
        {
            alerted=false;
            chdpaxno = Math.floor(under12counter) + Math.floor(chdcounter);
            infpaxno = Math.floor(under2counter) + Math.floor(infcounter);
            if((chdcounter==1&&infcounter==1)&&(nochd==1&&noin f==1))
            {
                alert("You have entered an incorrect Date of Birth for\nChild: " + forename.toProperCase() + " " + surname.toProperCase() + "\n" +
                "Infant: " + inf_forename.toProperCase() + " " + inf_surname.toProperCase() + "\n" +
                "A Child is classed as being aged between 2-12 (not inc.)\nA Infant is classed as being aged between 0-2 (not inc.)");
                alerted=true;
                //alert("824");
                chdalerted=true;
                infalerted=true;
                chdcounter=0;
                infcounter=0;
                document.form.chddate1.focus();
                confirm_redirect="yes";
            }


            if((chdcounter==2&&infcounter==1)&&(nochd==2&&noin f==1))
            {

                alert("You have entered an incorrect Date of Birth for\nChild: " + forename.toProperCase() + " " + surname.toProperCase() + "\n" +
                "Child: " + forename2.toProperCase() + " " + surname2.toProperCase() + "\nInfant: " + inf_forename.toProperCase() + " " + inf_surname.toProperCase() + "\n" +
                "A Child is classed as being aged between 2-12 (not inc.)\nA Infant is classed as being aged between 0-2 (not inc.)");
                alerted=true;
                //alert("850");
                chdalerted=true;
                infalerted=true;
                chdcounter=0;
                infcounter=0;
                document.form.chddate1.focus();
                //var answer = confirm("You will be redirected to the Flight Search screen");
                //if(answer)
                //{
                    //window.location="airbook.asp";
                //}
                //else
                //{
                    //window.location="airbook.asp";
                //}
                confirm_redirect="yes";
            }


            if((chdcounter==1&&infcounter==2)&&(nochd==1&&noin f==2))
            {
                alert("You have entered an incorrect Date of Birth for\nChild: " + forename.toProperCase() + " " + surname.toProperCase() + "\n" +
                "Infant: " + inf_forename.toProperCase() + " " + inf_surname.toProperCase() + "\n"+
                "Infant: " + inf_forename2.toProperCase() + " " + inf_surname2.toProperCase() + "A Child is classed as being aged between 2-12 (not inc.)\n"+
                "A Infant is classed as being aged between 0-2 (not inc.)");
                alerted=true;
                //alert("876");
                chdalerted=true;
                infalerted=true;
                chdcounter=0;
                infcounter=0;
                document.form.chddate1.focus();
                confirm_redirect="yes";
            }

            // TWO WRONG CHD DOB, TWO WRONG INF DOB
            if((chdcounter==2&&infcounter==2)&&(nochd==2&&noin f==2))
            {

                alert("You have entered an incorrect Date of Birth for\nChild: " + forename.toProperCase() + " " + surname.toProperCase() + "\n" +
                "Child: " + forename2.toProperCase() + " " + surname2.toProperCase() + "\nInfant: " + inf_forename.toProperCase() + " " + inf_surname.toProperCase() + "\n" +
                "Infant: " + inf_forename2.toProperCase() + " " + inf_surname2.toProperCase() + "A Child is classed as being aged between 2-12 (not inc.)\n" +
                "A Infant is classed as being aged between 0-2 (not inc.)");
                alerted=true;
                //alert("903");
                chdalerted=true;
                infalerted=true;
                chdcounter=0;
                infcounter=0;
                document.form.chddate1.focus();
                //var answer = confirm("You will be redirected to the Flight Search screen");
                //if(answer)
                //{
                    //window.location="airbook.asp";
                //}
                //else
                //{
                    //window.location="airbook.asp";
                //}
                confirm_redirect="yes";
            }

            // ONE WRONG CHD DOB, ONE WRONG INF DOB
            if((chdcounter==1&&infcounter==1)&&(nochd==2&&noin f==2))
            {

                alert("You have entered an incorrect Date of Birth for a Child and an Infant\n"+
                "A Child is classed as being aged between 2-12 (not inc.)\nA Infant is classed as being aged between 0-2 (not inc.)");
                alerted=true;
                //alert("928");
                chdalerted=true;
                infalerted=true;
                chdcounter=0;
                infcounter=0;
                document.form.chddate1.focus();
                confirm_redirect="yes";
            }

            // IF THERE HAS BEEN NO ALERTS THEN SHOW GENERIC ALERT
            if(alerted!=true)
            {
                if((all!=true)&&(confirm_redirect!="yes"))
                {
                    alert("You have entered an incorrect Date of Birth for Children and Infants\n"+
                    "A Child is classed as being aged between 2-12 (not inc.)\nA Infant is classed as being aged between 0-2 (not inc.)")
                    document.form.chddate1.focus();
                    confirm_redirect="yes";
                }
            }
        }

        // CHD: IF THERE ARE 1 OR MORE CHILDREN WITH INCORRECT DOB AND NO INCORRECT INFANT DOB
        if((Math.floor(chdcounter)!=0)&&(Math.floor(infcou nter)==0)&&(nochd==1)) // &&(nochd<2)
        {
            if(allkinder!=true)
            {
                chdpaxno = Math.floor(under12counter) + Math.floor(chdcounter);
                alert("You have entered an incorrect Date of Birth for\nChild: "+ forename.toProperCase() + " " + surname.toProperCase() +
                "\nChild must be aged 2-12 years old");
                chdcounter=0;
                chdalerted=true;
                //alert("978");
                document.form.chddate1.focus();
                confirm_redirect="yes";
            }

        }

        // IF THERE ARE 1 OR MORE INCORRECTLY ENTERED CHD DOB, NO INFANTS INCORRECT DOB AND MORE THAN ONE CHILD IN THE BOOKING
        else if((Math.floor(chdcounter)!=0)&&(Math.floor(infcou nter)==0)&&(nochd!=1)&&(chdalerted!=true)) // &&(duplikat_chd!=true)
        {
            //alert("990!");
            chd_generic=true;
            //alert("i (control loop) = " + i);
            duplikat_chd=true;
            //alert("unterschied = " + unterschied);

            if(parseFloat(unterschied)>120000)
            {
          &
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop down menu mizlatic BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 February 11th, 2008 07:02 AM
Drop down menu antoneath Beginning PHP 1 January 27th, 2006 08:45 AM
drop-down menu crmpicco Javascript How-To 1 March 22nd, 2005 01:23 PM
right click menu hidden by drop-drown menu Andraw HTML Code Clinic 0 March 18th, 2005 03:28 PM
drop down menu scrowler Javascript 1 January 27th, 2005 05:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.