Hello everyone,
I am placing this JavaScript code below in the calculate tab in the custom calculation script window for an Adobe acrobat form I am creating. The user will enter in the DOB field "mm/dd/year" and the age output should be in the "age" field. For the moment the code works up to the the day 12th day after that the age does not show up in the age field and if I put a date of 1/16/1973 my age should be 39, but my age comes out as 38. Can anyone tell me what I am missing in the code? All so its not accounting for the leap year. Any help will be appreciated. Thanks!
event.value = "";
dobValue = getField("dob").value;
if (dobValue!="") {
dob = util.scand("dd/mm/yyyy", dobValue);
today = new Date();
age = today.getFullYear() - dob.getFullYear();
if (today.getMonth() < dob.getMonth())
age;
else if (today.getMonth()== dob.getMonth())
age;
else if (today.getDate() < dob.getDate())
age;
else if (today.getDate() == dob.getDate())
age;
event.value = age;
}