PDF Editing Issues

How to Show a PDF Form Error When Percentage Total Is Not 100

Adam DavisAdam Davis Oct 28, 2026 870 views

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.

How to Show a PDF Form Error When the Percentage Total Is Not 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.
Before you start

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.

Solution 1Recommended

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.

1
Create the individual percentage fields

Open your PDF in form editing mode and insert Text Fields for each of the allocation rows where users will input their percentages.

2
Create a Total Field

Insert a new Text Field and name it 'Total Cert%'. Double-click it to open the Properties dialog.

3
Configure the calculation

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.

4
Add the validation script

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.");`

5
Save and test

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.

Prevent Decimal Precision Errors: If users are entering fractions (like 33.3%), floating-point math can cause false validation errors. Consider rounding values in your script using Math.round() before comparing them to 100.
Professional PDF Tools

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. 1. Launch WPS Office: Open WPS Office and import your static PDF document into the PDF Editor.
  2. 2. Open Form Editing: Click the 'Form' tab on the top toolbar to reveal the interactive form controls.
  3. 3. Insert Text Fields: Use the 'Text Field' tool to draw input boxes over your document lines.
  4. 4. Set Calculation Properties: Double-click the desired total field, navigate to the Calculate tab, and designate the fields to be summed up.
Easily add customizable text fields, checkboxes, and buttons.Fully compatible with standard Adobe Acrobat PDF forms and calculations.Intuitive graphical interface for setting up mathematical operations without extensive coding.Lightweight installation with blazing fast document loading times.
microsoft office alternative - wps office

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.