A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Date Of Birth Help!!!!

  1. #1
    Junior Member
    Join Date
    Aug 2003

    Date Of Birth Help!!!!

    Hi guys...

    Wondering if anyone can help with an issue I am having

    I am sending a form from Flash MX2k4

    using a basic on release that grabs variables from my form and passes them to an ASP page that processes the form..

    Here is the sticky part.

    One of the form fields is "UserAge" I am currently just passing it via an inout field and telling the user to use the format MM/DD/YYYY ( I realize that in itself may cause issues)

    My problem is I need to setup some type of verification that check to see if the user is over 13 years old.

    If they are 13, it passes/processes the form.

    If they are under 13, I just want to jump to a frame telling them they are too young)

    SOunds pretty simple and I have alreayd written this in ASP (works fine)

    But actionscript is making me batty...

    I guees what I am asking is for a simple way to grab the data from one of my forms input fields (data1 in this case) and do a quick calculation when they hit the submit button, and based on what the value in data1 is either have the form submit or just jump to another frame telling them they are too young to enter my contest

    I have an email format verify function in there and would like to just add it in the same onrelease.

    Here is the script attached to my send button

    on (release) {
    if (!data2.length || data2.indexOf("@") == -1 || data2.indexOf(".") == -1) {

    else {

    var thestrng = "?name=" + data0 + "&UserAge=" + data1 + "&email=" + data2 + "," + data3 + "," + data4 + "," + data5 + "," + data6 + "," + data7;
    getURL("http://www.somesite.com/passit.asp" + thestrng, "tracking", "GET");


    BONUS QUESTION: data3 thru data7 are all "freinds email addreses" anyone able to mod the mail format check at the top to check each one of them?

    I really appreciate any help you guys can offer....

    Have a great night..


  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Los Angeles
    Assuming you can get as far as getting your birthdate into a single variable, this'll determine if the user is 13 or older...


    // sample age
    userAge = "2/15/1972";

    userAgeArray = userAge.split('/');
    mon = Number(userAgeArray[0]);
    day = Number(userAgeArray[1]);
    year = Number(userAgeArray[2]);

    // in case user entered '64'
    if (year < 4)
    year += 2000;
    else if (year < 100)
    year += 1900;

    birthDate = new Date(year,mon-1,day);
    todayDate = new Date();
    elapsedYears = todayDate.getYear() - birthDate.getYear();

    if ((todayDate.getMonth() < birthDate.getMonth() ||
    (todayDate.getMonth() == birthDate.getMonth() &&
    todayDate.getDay() < birthDate.getDay())))
    trace("Age of user: " + elapsedYears);
    if (elapsedYears >= 13) {
    // pass
    else {
    // fail

    Edit: Fixed string->number problem, as described below...
    Last edited by jbum; 06-30-2004 at 03:15 AM.

  3. #3
    Senior Member
    Join Date
    Jun 2001
    great script (however)...

    the part where it fixes the year if you enter something other than 4 digits (like '64' instead of '1964' didn't work unless I modified the 6th line as such
    year = Number(userAgeArray[2]);
    otherwise it was treating the numbers as strings. So 64 was becoming 641900. And people were very old!

  4. #4
    Junior Member
    Join Date
    Aug 2003
    Thanks Fellas...

    You are Kings among Commoners...

    File this in the RESOLVED Folder

    Have a good one

    Beers and Buds are on me.


  5. #5
    Senior Member
    Join Date
    Sep 2002
    For anyone else who finds this thread..
    The getDay method only returns the "day" ie: monday - friday.. to find out the date ie: 27th then use the getDate() function.. if you replace this line of coed it will correctly display the age in years down to the day.

    if ((todayDate.getMonth()<birthDate.getMonth() || (todayDate.getMonth() == birthDate.getMonth() && todayDate.getDate()<birthDate.getDate()))) {

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center