How to Show a PDF Form Error When Percentage Total Is Not 100
Question details
The user needs a way to validate a PDF form containing multiple account-allocation rows, triggering an error message if the total sum of the percentage fields does not equal 100.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form where respondents must allocate percentages across multiple fields, and the total must be exactly 100%.
- Observed behavior
- A calculated field computes the sum, but without validation, the form accepts invalid totals. The goal state is to trigger a popup alert warning the user if the calculation is anything other than 100.
Ensure you have a PDF editor that supports interactive form field creation and custom JavaScript execution. Take note of the exact field names you plan to include in the calculation.
Use a Calculated Field with a JavaScript Validation Rule
Create a total field that automatically sums the individual percentage rows, and apply a custom script to validate the final amount.
By setting up a 'Total Cert%' field, the PDF can automatically calculate the sum of multiple individual fields while treating blank entries as zero. Adding a simple JavaScript validation to this total field ensures the respondent is instantly notified if their math is incorrect.
Open your PDF in form editing mode and insert Text Fields for each of the allocation rows where users will input their percentages.
Insert a new Text Field and name it 'Total Cert%'. Double-click it to open the Properties dialog.
Navigate to the Calculate tab within the Properties dialog. Select 'Value is the sum of the following fields' and pick all the individual percentage fields you created earlier.
Switch to the Validate tab. Choose 'Run custom validation script', click 'Edit', and enter the following code: `if (event.value != 100) app.alert("The total percentage must equal 100.");`
Close the properties window, save your PDF, and test the form by entering numbers that sum to more or less than 100 to verify the popup alert appears.
Design Interactive PDF Forms with WPS Office
WPS Office provides robust PDF editing capabilities, enabling you to effortlessly build interactive forms, configure field calculations, and gather data securely.
- 1. Launch WPS Office: Open WPS Office and import your static PDF document into the PDF Editor.
- 2. Open Form Editing: Click the 'Form' tab on the top toolbar to reveal the interactive form controls.
- 3. Insert Text Fields: Use the 'Text Field' tool to draw input boxes over your document lines.
- 4. Set Calculation Properties: Double-click the desired total field, navigate to the Calculate tab, and designate the fields to be summed up.

Frequently Asked Questions
Can I prevent the form from being submitted if the total isn't 100?
Yes. Instead of attaching the validation script to the total field itself, attach a custom JavaScript action to the 'Submit' button. The script can check the total field's value and cancel the submission process if the value does not equal 100.
Why does my total field ignore blank rows?
Standard PDF form calculations typically treat blank text fields as zero. This behavior is expected and ensures that your total calculation does not break if a user leaves a non-applicable percentage field empty.
How do I hide the total field until the user starts typing?
You can add a custom formatting script to your total field that checks if the value is zero. If the total is zero (which is the default when all fields are blank), the script can set the display value to an empty string.




