Solved

AGE VERIFICATION SCRIPT NEEDED

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

839 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