Monday, July 18, 2011

Javascript Validate Date of Birth

2 comments:

  1. I have a doubt. I may be wrong, so I am sorry if I am wrong. But the condition where you are checking for leap year, shouldn't it be (day == 29 && isleap) and return as true?

    ReplyDelete
  2. Sorry for delayed response, I have done all of 'if' conditions are indented to say to "FALSE" and If all 'if' condition fails, then it is simply valid date.

    In the same way, I have done condition to say FALSE when user input contains the date 29 in non leap year.

    Yes, If I wanted to say "TRUE" in middle of function execution, then I have to write as follows
    if(day < 29 || (day == 29 && isleap)){
    return true;
    }

    ReplyDelete