function calAge(bDay){
var born;
now = new Date()
bD = bDay.value.split('-');
if(bD.length!=3){
alert('Date Is Not Valid');
MyForm.age.value="";
}
else if(bD.length==3){
born = new Date(bD[2], bD[1]*1-1, bD[0]);
years = Math.floor((now.getTime() - born.getTime()) / (365.25 * 24 * 60 * 60 * 1000));
MyForm.age.value = years;
}
}
No comments:
Post a Comment