Solved

javascript

Posted on 2006-07-03
2
211 Views
Last Modified: 2010-03-31
Hello can anyone help me please!!

In the following javascript code, but more speciffically the IF(TODAY == */*/1989 || TODAY == */*/1901).  What I am trying to do is allow the */* to be any number.  So what I am checking is that if TODAY is equal to <any number>/<any number>/1989 or <any number>/<any number>/1901 then an alert should be given.  

Thanks in advance!

function CHECKFORM() {
        var TODAY = new Date()
        TODAY = Date.parse(TODAY)
        var BIRTHDAY = document.forms[0].BIRTHDAY.value
       
        if (!isDate(BIRTHDAY)) {
            alert("PROVIDE A VALID DATE.  Format = mm/dd/yyyy")
            return false
        }
       
        BIRTHDAY = Date.parse(BIRTHDAY)
       
        if (TODAY == */*/1989 || TODAY == */*/1901) {
            alert("Sorry, you need to be at least 18 years of age, but younger then 105")
            return false
        }
        return true
    }
0
Comment
Question by:meaar
2 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
you'd be better of asking in the javascipt ta
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/
0
 
LVL 10

Accepted Solution

by:
mukundha_expert earned 500 total points
Comment Utility
You can get the year like this,

      var TODAY = new Date()
        //TODAY = Date.parse(TODAY)
        day = TODAY.getDay() ;
        month = TODAY.getYear () ;
        year = TODAY.getYear () ;

compare the year to the year you wanted, else subtract it from the birthday's year to find whether the user is 18 years above age
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 75
Enhanced For loop vs ForEach Loop 4 54
countHi2 challenge 7 43
topping1 challenge 7 48
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

771 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

12 Experts available now in Live!

Get 1:1 Help Now