PDF Editing Issues

Validate PDF Percentage Fields in Adobe Acrobat When Their Total Reaches 100%

Amos GikundaAmos Gikunda Nov 19, 2026 868 views

Question details

Create a PDF form calculation that checks whether five or six completed percentage fields add up to 100%.

Validate Percentage Fields in an Adobe Acrobat PDF Form
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A form user enters percentages in several fields, and the form should validate the total only after every field has a value.
Observed behavior
The desired result is an alert when all percentage fields are complete but their sum is not 100%.
Before you start

Open the PDF in Acrobat with form editing available and identify the exact names of the input fields and the separate total field. Set the inputs to Number format and ask users to enter whole-percentage values, such as 25 for 25%, rather than using Acrobat's Percentage format.

Solution 1Recommended

Add a custom calculation script to the total field

Use this script to display a running total and alert users only after all listed fields contain numbers.

The script treats 0 as a completed value and allows a small tolerance for decimal rounding. Leave input fields blank by default if they must be filled in by the user.

1
Open the form editor

In Acrobat, open the PDF and select All tools > Prepare a form. Confirm that the input fields and a separate total field exist.

2
Open the total field calculation

Double-click the total field, open its Properties, select the Calculate tab, and choose Custom calculation script. Select Edit to open the script editor.

3
Paste and adapt the script

Paste this script into the editor: var names = ["Text1", "Text2", "Text3", "Text4", "Text5", "Text6"]; var sum = 0; var complete = true; for (var i = 0; i < names.length; i++) { var field = this.getField(names[i]); if (!field || field.valueAsString.replace(/^\s+|\s+$/g, "") === "") { complete = false; } else { var value = Number(field.value); if (!isFinite(value)) { complete = false; } else { sum += value; } } } event.value = sum; if (complete && Math.abs(sum - 100) > 0.0000001) { app.alert("The percentages must add up to 100%."); } Replace the names in the array with the exact input field names. Remove one name if the form has five fields.

4
Save and test the form

Close the Properties dialog, save the PDF, and test it in Preview. Try leaving a field blank, entering 0, and completing all fields with totals of 100 and a value other than 100.

Add a custom calculation script to the total field
Alerts can repeat: Acrobat may recalculate the total after other form changes, so the alert can appear again while all fields are complete and the total is incorrect.
Free Microsoft Office alternative

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 Microsoft Office files. Its format compatibility helps with migration, but the Acrobat-specific form calculation script requires Acrobat.

Open and review PDF documents alongside Office filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for a smoother transition from Microsoft OfficeFree, lightweight tools for everyday document work
microsoft office alternative - wps office

Frequently Asked Questions

Can a percentage field contain 0?

Yes. The script checks whether the field is blank, so an entered 0 counts as a completed value.

How do I change the script for five fields?

In the total field's Properties > Calculate > Custom calculation script, remove one field name from the names array. Make sure the remaining names match the form fields exactly.

Why does the script compare the total with 100 instead of 1?

It assumes Number-formatted fields where users enter 25 for 25%. Acrobat's Percentage format can use a different underlying value, so this script should not be used with that format without adjustment.

Why does the alert appear more than once?

The custom calculation can run whenever Acrobat recalculates the form. If all fields are filled and the total remains incorrect, it may show the alert again.