I have 2 textboxes , txtDOB and txtAge
I am using jquery datepicker to get the date in txtDOB (date of birth textbox)
What i want is when i select date of birth from datepicker in my date of birth textbox i.e txtDOB
I want the age to be calculated automatically On age textbox i.e txtAge
I searched on internet but i am not finding the perfect one. I am stuck so far i have not done any coding to calculate age based on DOB.
Any help or any suggestion will be much appreciated
Thanks
Santhosh KumarPosted Nov 25, 2016, 7:39 AM
Sonu ChaudharyPosted Jun 6, 2016, 1:48 PM
var d1 = $('.txtDOB').datepicker('getDate');
var d2 = new Date();
var oneDay = 364*24*60*60*1000;
var diff = 0;
if (d1 && d2) {
diff = Math.round(Math.abs((d2.getTime() - d1.getTime())/(oneDay)));
}
$('.calculated').val(diff);
$('.txtAge').val(d1)
}