Limit Adobe Acrobat PDF Form Entries and Validate a 100% Total
Question details
Create a PDF form that counts completed fields, totals their values, and flags more than 14 entries or a final total other than 100%.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A form allows users to distribute percentage values across multiple fields and check their entries when finished.
- Observed behavior
- The desired form should permit partial totals during entry, calculate the total, and warn users if the final entries exceed the field limit or do not add up to 100%.
Open the form in Adobe Acrobat Pro and identify the names of all percentage-entry fields. Decide whether users will enter whole percentage values, such as 20 for 20%, and use the same convention throughout the form.
Calculate the total and flag invalid entries with Acrobat JavaScript
Use a calculated total field and a validation button to flag excess entries and check the final total without interrupting partial entry.
This example uses 20 text fields named Field1 through Field20 and a text field named Total. Adjust the field names and loop limit in both scripts to match your form. Users should enter numbers from 0 to 100 without a percent sign; do not apply Acrobat's percentage format to these fields.
The validation button flags errors rather than blocking additional entries. It does not automatically prevent submission through a separate Submit button.
Open the PDF in Acrobat Pro and choose All tools > Prepare a form. Create or rename the entry fields as Field1 through Field20, and add a text field named Total. In Total's properties, select Read Only.
Open Total's Properties > Calculate, select Custom calculation script, and click Edit. Enter this script: var sum = 0; for (var i = 1; i <= 20; i++) { var s = this.getField('Field' + i).valueAsString.replace(/^\s+|\s+$/g, ''); if (s !== '' && isFinite(Number(s))) sum += Number(s); } event.value = sum; The total updates as fields change. The validation button checks for invalid values.
In Prepare a form, add a button labeled Check entries. Open its Properties > Actions, choose Mouse Up and Run a JavaScript, then click Add. Enter: var count = 0, sum = 0, invalid = false; for (var i = 1; i <= 20; i++) { var s = this.getField('Field' + i).valueAsString.replace(/^\s+|\s+$/g, ''); if (s !== '') { count++; var n = Number(s); if (!isFinite(n) || n < 0 || n > 100) invalid = true; else sum += n; } } if (invalid) app.alert('Enter numbers from 0 to 100, without percent signs.'); else if (count > 14) app.alert('Complete no more than 14 fields.'); else if (Math.abs(sum - 100) > 0.000001) app.alert('The total must equal 100%. Current total: ' + sum + '%.'); else app.alert('The entries are valid and total 100%.');
Save the PDF, open it in a PDF viewer that supports Acrobat form JavaScript, and enter 20 and 80 in two fields. Click Check entries, then test a partial total and 15 completed fields to confirm the warnings.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs, documents, and spreadsheets. Its Microsoft Office format support helps you move existing files into your workflow. The Acrobat JavaScript validation described above still requires a compatible PDF editor and viewer.

Frequently Asked Questions
Why shouldn't the form reject a total below 100% immediately?
A partial total is normal while someone fills in the form. For example, entering 20 before 80 temporarily produces a total of 20%. Check the final total with a validation button instead.
How do I flag the 15th completed field?
Count nonempty fields and check whether count > 14. The example's Check entries button displays a warning when more than 14 fields are complete.
Does a field containing zero count as completed?
Yes. The example counts any nonempty field, including one containing 0. Leave the field blank if it should not count toward the limit.
Can users submit an invalid form with this button?
A separate Submit button could still submit it. Add equivalent checks to the submission workflow if invalid entries must be blocked, and test that workflow in the intended PDF viewer.
Will the scripts work in every PDF viewer?
No. Some viewers do not support Acrobat form JavaScript. Test the saved form in the viewer recipients will use, including its calculation and button actions.




