I was able to populate months, days and years. I was also able to determine the age, which in my end I am only allowing up to age 13.
Here is my code:
$('#reg-yr').change(function(){ var year = $('#reg-yr').val(); var month = $('#reg-mn').val(); var date = $('#reg-dt').val(); var firstdate=new Date(year,month,date); var today = new Date(); var dayDiff = Math.ceil(today.getTime() - firstdate.getTime()) / (1000 * 60 * 60 * 24 * 365); var age = parseInt(dayDiff);});
This code checks the age when year was change. What I am having problem right now, is how to populate the month drop-down field based on the age.
For example:The date today is June 13, 2014
My default date in my birthday drop-down is January 1, 1980
What I wanted is for example when I change the year to 2001, the month will be populated based on maximum age.
So the drop-down should be only consisting months of January down to May.
Thank you for the help.