Add Age to a PDF Form Calculation in Adobe Acrobat
Question details
Add age as an input to an existing Acrobat PDF form calculation.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form calculates a body-fat estimate or another health value, and the user wants to include age.
- Observed behavior
- The desired calculation reads an age field and applies the rules of the chosen formula.
Identify the exact formula, applicable age ranges, and names of the existing form fields. Standard adult BMI uses weight and height, not age; age may be relevant to a separate body-fat formula or to interpreting BMI for children.
Add the Age Field to the Acrobat Calculation Script
Use this approach when you have an existing calculated field and know how the selected formula uses age.
Open the PDF in Acrobat and choose All tools > Prepare a form. Select the existing age field, or add a text field and name it Age.
Double-click the calculated result field, open Properties > Calculate, select Custom calculation script, and click Edit. Note the field names already used by the script.
In the JavaScript editor, read the age field with `var ageText = this.getField("Age").valueAsString;` and convert it with `var age = Number(ageText);`. Replace Age with the exact field name if necessary. Check that the field is not blank, that age is a valid number, and that it falls within the formula's supported range before calculating.
Update the existing calculation logic to use the validated `age` variable according to the specified formula and age rules. Assign the resulting value to `event.value`; set `event.value` to an empty string when required inputs are invalid. Click OK to save the script.
Close the form editor or use Preview, then enter values in the age and other input fields. Test valid values, blank and invalid inputs, and any age-range boundaries against known results for the chosen formula.

Work With PDF and Office Files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Office files. Its format support helps make the move from Microsoft Office straightforward. Use Adobe Acrobat to edit and test Acrobat-specific form JavaScript.

Frequently Asked Questions
Does age change the standard adult BMI calculation?
No. Standard adult BMI is calculated from weight and height. Age may be used in a separate body-fat estimate or when interpreting BMI for children.
Where can I find the calculated field's JavaScript?
In Acrobat, choose All tools > Prepare a form, double-click the result field, and open Properties > Calculate. If Custom calculation script is selected, click Edit to view the script.
Why is the age value not available to my script?
Check the age field's name in its Properties and use that exact name in `this.getField("Age")`. Also check that the field contains a valid number before applying the formula.
How can I check that the updated formula works?
Use Preview in Prepare a form and enter known test values, including age-range boundaries and invalid inputs. Compare the results with expected values from the chosen formula.




