Solved

AGE VERIFICATION SCRIPT NEEDED

Posted on 2004-04-01
2
806 Views
Last Modified: 2012-06-21
Hi Experts,

I need to verify an age input to ensure that the user who inputs their age on a form is under 65 years old. The age input is as follows:

          <select name="dobDay" size="1" class="formStyle">
            <option value="-1">Day</option>
            <%
                        FOR i = 1 TO 31
                          m = " "
                          IF i = DatePart("d",Now) THEN
                      m = " selected "
                          END IF
                    %>
            <option<%=m%>value="<%=i%>"><%=i%></option>
            <%
                        NEXT
                    %>
          </select>
      /
      <select name="dobMonth" size="1" class="formStyle">
        <option value="-1">Mth</option>
        <%
                      FOR j = 1 TO 12
                          m = " "
                          IF j = DatePart("m",Now) THEN
                      m = " selected "
                          END IF
                   %>
        <option<%=m%>value="<%=j%>"><%=j%></option>
        <%
                        NEXT
                  %>
      </select>
      /
      <select name="dobYear" size="1" class="formStyle">
        <option value="-1">Yr</option>
        <%
                        FOR k = CInt(DatePart("yyyy",Now))-66 TO DatePart("yyyy",Now)
                          m = " "
                          IF k = DatePart("yyyy",Now) THEN
                      m = " selected "
                          END IF
                  %>
        <option<%=m%>value="<%=k%>"><%=k%></option>
        <%
                        NEXT
                  %>
      </select>


So it's a 3 drop down date input "dobDay" "dobMonth" dobYear"


Do any of you have any examples I could use?



Thanks,



PJORDANNA

0
Comment
Question by:pjordanna
2 Comments
 

Author Comment

by:pjordanna
ID: 10730990
The validation will occur on the form submit.



PJORDANNA
0
 
LVL 6

Accepted Solution

by:
jarasa earned 500 total points
ID: 10731237
Take a look at this and you can make the appropite changes:

// Check that string theField.value is a valid Year.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkYear (theField, emptyOK)
{   if (checkYear.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isYear(theField.value, false))
       return warnInvalid (theField, iYear);
    else return true;
}


// Check that string theField.value is a valid Month.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkMonth (theField, emptyOK)
{   if (checkMonth.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isMonth(theField.value, false))
       return warnInvalid (theField, iMonth);
    else return true;
}


// Check that string theField.value is a valid Day.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkDay (theField, emptyOK)
{   if (checkDay.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    if (!isDay(theField.value, false))
       return warnInvalid (theField, iDay);
    else return true;
}



// checkDate (yearField, monthField, dayField, STRING labelString [, OKtoOmitDay==false])
//
// Check that yearField.value, monthField.value, and dayField.value
// form a valid date.
//
// If they don't, labelString (the name of the date, like "Birth Date")
// is displayed to tell the user which date field is invalid.
//
// If it is OK for the day field to be empty, set optional argument
// OKtoOmitDay to true.  It defaults to false.

function checkDate (yearField, monthField, dayField, labelString, OKtoOmitDay)
{   // Next line is needed on NN3 to avoid "undefined is not a number" error
    // in equality comparison below.
    if (checkDate.arguments.length == 4) OKtoOmitDay = false;
    if (!isYear(yearField.value)) return warnInvalid (yearField, iYear);
    if (!isMonth(monthField.value)) return warnInvalid (monthField, iMonth);
    if ( (OKtoOmitDay == true) && isEmpty(dayField.value) ) return true;
    else if (!isDay(dayField.value))
       return warnInvalid (dayField, iDay);
    if (isDate (yearField.value, monthField.value, dayField.value))
       return true;
    alert (iDatePrefix + labelString + iDateSuffix)
    return false
}

Javier
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now