Copy link to clipboard
Copied
Currently, these are the fields I have.
DoB Field name: Date of Birth
Date Field name: Date of Today [Calculated using the following script] which is read-only so every time our front desk opens this document, the date is automatically filled.
var fld = this.getField("Date of Today"); fld.value = util.printd("mm/dd/yyyy",new Date());Age field name: Age
I am using Acrobat DC. I have my Age to "read-only" as well. Currently, I have this script running and nothing is populating on the Age fields.
event.value = "";
var dobValue = getField("Date of Birth").value;
if (dobValue!="") {
var dob = util.scand("mm/dd/yyyy", dobValue);
var today = new Date();
var age = today.getFullYear() - dob.getFullYear();
if (today.getMonth() < dob.getMonth()) age = age - 1;
if ((today.getMonth() == dob.getMonth()) && (today.getDate() < dob.getDate())) age -= 1;
event.value = age;
}Help me out on this? I have absolutely no knowledge of Java at all. I am just following instructions on the web.
Copy link to clipboard
Copied
Use the script at calculation of field Age.
Copy link to clipboard
Copied
Where does you use the script?
Copy link to clipboard
Copied
I am placing the scripts in the Documents JavaScript
Copy link to clipboard
Copied
Use the script at calculation of field Age.
Copy link to clipboard
Copied
This helped so much! Solved! Thank you!!!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more