Multiply an Acrobat Form Field and Return Four Characters
Question details
The user wants to multiply a PDF form field by 150 and display the first four characters of the result in another field.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form needs a destination field that calculates a value from a source field.
- Observed behavior
- The destination field should show the first four characters of the calculated result, or remain blank if the result has fewer than four characters.
Open the PDF in Acrobat and confirm that it contains a source text field and a destination text field. Check the source field's exact name in its properties, and make sure Acrobat JavaScript is enabled in Preferences.
Add a custom calculation script to the destination field
Use this method to calculate the result automatically in an Acrobat PDF form.
In Acrobat, open the PDF and select Prepare a Form from the tools menu.
Double-click the destination text field, such as Text2, and select the Calculate tab.
Select Custom calculation script, click Edit, and enter: var num = Number(this.getField("Text1.0.1").valueAsString) * 150; var str = num.toString().slice(0, 4); if (str.length == 4) event.value = str; else event.value = ""; Replace Text1.0.1 with the exact name of your source field.
Confirm the script, close the field properties, and save the PDF. Enter 10 in the source field to check that the destination displays 1500; entering 5 should leave it blank.
To calculate from another source field, open the corresponding destination field's Calculate tab, copy the script, and update the source field name.

Calculate form values in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar interface and support for common Office formats, making it easy to move existing files. Use WPS Spreadsheets for a worksheet-based version of this calculation; it does not add an Acrobat calculation script to a PDF form.

Frequently Asked Questions
Where do I find the custom calculation script box in Acrobat?
Open Prepare a Form, double-click the destination field, and select Calculate. Choose Custom calculation script and click Edit.
Why is the destination field blank when the result is 750?
The script displays a value only when the sliced result contains four characters. Since 750 has only three, the destination field is cleared.
How do I use the script with a different source field?
In the destination field's custom calculation script, replace Text1.0.1 inside this.getField() with the exact name shown in the source field's properties.
Does the script always return four numeric digits?
No. It returns the first four characters of the result's text representation. For negative or decimal results, a minus sign or decimal point can be included.




