PDF Editing Issues

Auto-Fill a PDF Field Based on Age in Adobe Acrobat

Emma BrownEmma Brown Nov 19, 2026 868 views

Question details

Automatically populate one PDF form field based on the age entered in another field.

Product
PDF form fields
Device & OS
not provided
Scenario
A form needs to assign a result according to an age entered in a source field.
Observed behavior
The destination field should show a value determined by the source age range.
Before you start

Identify the exact name of the field that holds the age and the destination field that should display the result. You need a PDF form editor that supports custom calculation scripts, such as Adobe Acrobat Pro.

Solution 1Recommended

Add a Custom Calculation Script to the Destination Field

Use this method to return 4 for ages 45–100, 0 for ages 1–44, and a blank result for other values.

1
Open the form editor

Open the PDF in Adobe Acrobat Pro and select All tools > Prepare a form.

2
Check the field names

Double-click the age field and check its name on the General tab. Create or identify a separate text field for the calculated result.

3
Add the calculation

Double-click the destination field, open the Calculate tab, select Custom calculation script, and click Edit. Enter this script, replacing AgeField with the exact source field name: var age = Number(this.getField("AgeField").value); if (age >= 45 && age <= 100) event.value = "4"; else if (age >= 1 && age <= 44) event.value = "0"; else event.value = "";

4
Check calculation order

In Prepare a form, open More > Set field calculation order. If the age field is itself calculated, move it before the destination field, then save the PDF.

5
Test the form

Exit form editing and enter ages such as 20, 45, and 101 in the age field. Confirm that the destination shows 0, 4, and blank, respectively.

Add a Custom Calculation Script to the Destination Field
Viewer and range limitations: The script leaves values between 44 and 45, as well as values outside the stated ranges, blank. PDF viewers that do not support or allow form JavaScript may not run the calculation.
Free Microsoft Office alternative

Edit PDF Documents and Office Files with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Microsoft Office files. Its format compatibility makes it easy to move existing documents into WPS; use a PDF editor that supports custom calculation scripts for the age-based automation described above.

Open and edit PDF documents alongside other office files.Work with Microsoft Word, Excel, and PowerPoint formats.Use a familiar interface for everyday document tasks.Move existing Office files into a lightweight workspace.
microsoft office alternative - wps office

Frequently Asked Questions

Where do I put the age calculation script?

In Adobe Acrobat Pro, open All tools > Prepare a form, double-click the destination field, and select Calculate > Custom calculation script > Edit.

What should I replace AgeField with?

Replace AgeField in the script with the exact name shown on the General tab of the source age field's properties. Keep the name inside quotation marks.

Why is the result blank for an age of 44.5?

The specified ranges end at 44 and begin again at 45, so 44.5 falls between them. Adjust the conditions in the custom calculation script if fractional ages should receive a result.

Will the calculation work in every PDF viewer?

No. The viewer must support and allow PDF form JavaScript. Test the saved form in the viewer your recipients will use.