Solved

AGE VERIFICATION SCRIPT NEEDED

Posted on 2004-04-01
2
808 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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 …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

813 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

10 Experts available now in Live!

Get 1:1 Help Now