Solved

javascript

Posted on 2006-07-03
2
213 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
ID: 17034484
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
ID: 17034673
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

773 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