Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 7th, 2005, 05:59 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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 RegExp

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
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RegExp Problem Abbas Classic ASP Professional 0 August 2nd, 2006 10:48 AM
Regexp how to (also Urgent) NEO1976 Javascript 1 July 10th, 2006 08:54 AM
RegExp crmpicco Classic ASP Basics 0 June 6th, 2005 05:54 AM
RegExp Nitin_sharma Javascript 2 November 30th, 2004 07:21 AM
regexp problem godhsf80 PHP How-To 2 March 10th, 2004 04:54 AM



All times are GMT -4. The time now is 10:02 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.