Compare a Calculated PDF Field With 30 in Acrobat JavaScript
Question details
The user needs an Acrobat JavaScript condition that writes custom text to another PDF form field when a calculated value is above or below 30.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A calculated PDF form field is compared with 30 to determine the text shown in a second field.
- Observed behavior
- The second field should show the appropriate custom text for values above or below 30, with an explicit outcome for a value of 30.
Identify the exact names of the calculated source field and the text field that will display the result. Open the PDF in a version of Acrobat that lets you edit form fields, and check that JavaScript is enabled in Acrobat preferences.
Add a comparison script to the destination field
Use a custom calculation script to display different text above and below 30 without replacing the source field's existing calculation.
In Acrobat, open the PDF and choose All tools > Prepare a form. Open Properties for the destination text field, such as field "28".
On the Calculate tab, select Custom calculation script and click Edit. Replace "Calculated" with the exact source field name, then enter: var raw = this.getField("Calculated").value; if (raw === "" || raw == null || isNaN(Number(raw))) { event.value = ""; } else if (Number(raw) < 30) { event.value = "Text for below 30"; } else if (Number(raw) > 30) { event.value = "Text for above 30"; } else { event.value = ""; // Value is exactly 30 }
In Prepare a form, use More > Set Field Calculation Order and place the calculated source field before the destination field. Menu names may vary by Acrobat version.
Save the PDF, exit form editing, and enter values that produce results below, above, and equal to 30. Confirm that the destination field displays the intended text.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility helps you move existing files into your workflow, though it does not fix Acrobat JavaScript behavior.

Frequently Asked Questions
How do I run the same action for every value except 30?
After checking that the value is numeric, use a condition such as if (Number(raw) != 30). This includes values both below and above 30.
Why is the destination field showing an old result?
In Prepare a form, open More > Set Field Calculation Order and make sure the source calculated field comes before the destination field.
What does event.value refer to in the example?
In the destination field's custom calculation script, event.value is the value that will be displayed in that destination field. The script reads the source separately with this.getField("Calculated").value.
Can I show a message when the value is exactly 30?
Yes. Replace the empty string in the final else branch with your message, such as event.value = "Value is 30".




