How to compare age with date of birth in JavaScript? [duplicate]

0

I have a tremendous doubt. Do not ask me why, but I have to compare the age typed with the date of birth typed to see if they beat but I can not. Please, whoever can help me, I thank you.

    
asked by anonymous 23.06.2015 / 02:31

1 answer

1

Friend, you can check by subtracting the year of birth for the current year, if the reported birth date has not yet passed, subtract 1.

In this link you have an example of part of your question, the person needed to know the age from the date of birth.

  

#

After discovering the age using this function, simply make a simple if comparing the ages.

Follow the example link , hope it helps. :)

Another more elegant solution is to build a Regex.

    
23.06.2015 / 02:44