Solved

AGE VERIFICATION SCRIPT NEEDED

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

757 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

22 Experts available now in Live!

Get 1:1 Help Now