DOB validation

Hi, I am new member here and this is my first post.
I am having prob.
i want to validate user dob (only year) using java script.
1-else if age is less then 20 message should be "not enough"
2-else message should be "welcome".
But it show "welcome" message if field is empty. please check and help me.any help will be appreciated.

The code below will do what your asking for, but you should also check / validate the month and day too; to ensure 100% accurate "Client Side" Age Verification. Plus you should also validate the format of your DOB text field.

Ok brother i got it to some extent,please tell me what is the logic of using userdob="undefined" and userdob="NaN".
I mean to say when a text_field is said to be "undefined" and when said to be "NaN".
Also tell me how to find difference between two complete dates
that mean DD/MM/YYYY 00:00:00.

Ok brother i got it to some extent,please tell me what is the logic of using userdob="undefined" and userdob="NaN".
I mean to say when a text_field is said to be "undefined" and when said to be "NaN".

When I declared the variable "usrdob"; I parsed it as an interger, so I could do math (as it was originally a string). When I validated the "usrdob" variable; I converted back from an integer to a string. If the "usrdob" variable does not exsist, then the "usrdob" is "undefined" and if the "usrdob" variable is anything other then a integer (like any other character on your keyboard); you get "NaN", because it was originally parsed as an integer.

Originally Posted by atta_akbar

Also tell me how to find difference between two complete dates that mean DD/MM/YYYY 00:00:00.

Do it similar to the way I did the year. Split it up into two sections and validate each section; with a specific validation criteria. Just look @ how I did the year; try to do the month and day the same way. I wouldn't worry about the time; that is to specific of a DOB validation - lol.