I have user form, and i would like htat when the user enters the Date of birth, JQUERY to workout their age and if they are over 35 it will show a hidden div.
so far i have managed to piece this together
$(document).ready(function() {
$('#dob').datepicker({
onSelect: function(value, ui) {
var today = new Date(),
dob = new Date(value),
age = new Date(today - dob).getFullYear() - 1970;
$('#age').text(age);
},
maxDate: '+0d',
yearRange: '1960:2010',
changeMonth: true,
changeYear: true
});
if ($(age).val() >= 35) {
// do something
alert("35");
}else{
alert("not 35");
}
});
But it shows the alert on page load, i sure i have just put something in the wrong place, but i dont know what. I have put the alerts in just to text what was working, i will be replacing that with show() one i get it working. In all fairness im not actually bothered about having the datepicker, it was there in an example i found, so i kept it, if its easier to do with out it, then htats fine.
Thanks.