PDF Editing Issues

How to Fix Acrobat Adding 1 and 1 as 11 in PDF Forms

Algirdas JasaitisAlgirdas Jasaitis Nov 10, 2026 869 views

Question details

The user needs to know how to resolve an issue where mathematical addition in a PDF form results in concatenation.

How to Fix Acrobat Adding 1 and 1 as 11 in PDF Forms
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Setting up custom JavaScript calculation scripts in PDF form fields.
Observed behavior
Acrobat JavaScript treats empty or improperly formatted numeric form fields as strings, meaning the plus operator concatenates the values (returning '11' instead of '2') rather than adding them.
Before you start

Ensure you have access to edit the PDF form's properties and double-check the exact names of the text fields you intend to calculate.

Solution 1Recommended

Force Numeric Conversion in Custom JavaScript Calculation

Use the JavaScript Number() function to ensure that all retrieved field values are treated as integers or decimals before performing addition.

When a form field is empty or strictly evaluated, Acrobat treats its content as a string of text. Because JavaScript uses the plus (+) operator for both mathematical addition and text concatenation, adding two string values together places them side-by-side. By wrapping your field value retrievals in the Number() function, you explicitly instruct the script to perform a mathematical addition.

1
Open Field Properties

Open your PDF form in edit mode, right-click the target field where you want the sum to appear, and select 'Properties'.

2
Access Calculation Settings

Navigate to the 'Calculate' tab in the Properties dialog box and select the 'Custom calculation script' option.

3
Edit the JavaScript Code

Click the 'Edit' button and rewrite your formula using the Number() function. For example: event.value = Number(this.getField('line2a').value) + Number(this.getField('line2b').value);

4
Handle Zero Values (Optional)

To prevent the field from displaying a '0' when the source fields are blank, add an if-statement on the next line: if (event.value <= 0) event.value = '';

Force Numeric Conversion in Custom JavaScript Calculation
Syntax Accuracy: Always verify that the string inside getField() matches the exact case and spelling of your existing form fields.
Powerful PDF Editor

Create and Edit PDF Forms with WPS Office

WPS Office offers a comprehensive PDF editor that allows you to create interactive forms, manage field properties, and perform calculations without needing complex script troubleshooting.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open your PDF document using the PDF editor.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all form creation and editing tools.
  3. 3. Configure Calculations: Double-click the target text field to open its properties, go to the 'Calculate' tab, and configure your sum or custom scripts seamlessly.
Easily insert interactive text fields, checkboxes, and calculation fieldsFully compatible with standard Adobe PDF form formatsUser-friendly interface for managing form properties and arithmeticLightweight software that runs smoothly on low-spec devices
microsoft office alternative - wps office

Frequently Asked Questions

Can I perform addition in a PDF form without using custom JavaScript?

Yes. If you simply need to add values together, open the field properties, go to the Calculate tab, select 'Value is the sum (+)', and pick the specific fields you want to add. This bypasses the need for JavaScript entirely.

Why does multiplication or division work fine without the Number() function?

JavaScript only uses the plus (+) symbol for two different operations: addition and string concatenation. For multiplication (*), division (/), or subtraction (-), JavaScript automatically attempts to convert the strings into numbers because those operators only apply to math.

How do I fix a 'NaN' error in my PDF form calculation?

A 'NaN' (Not a Number) error occurs when the script tries to calculate text that cannot be converted to a number. Ensure that the input fields restrict characters to numbers only, and verify that your getField() spelling is perfectly accurate.