PDF Editing Issues

How to Fix PDF Form Calculations Treating Numbers as Text

Olivia MillerOlivia Miller Nov 3, 2026 870 views

Question details

The user needs to correct a PDF form calculation issue where mathematical addition functions act as string concatenation.

How to Fix PDF Form Calculations Treating Numbers as Text
Product
PDF Editor
Device & OS
not provided
Scenario
Designing or filling out interactive PDF forms with automated calculation scripts.
Observed behavior
When adding field values together, the numbers are processed as text strings, causing them to append rather than calculate mathematically (e.g., 10 + 0 results in 100 instead of 10).
Before you start

Ensure you have permission to edit the interactive form fields within your PDF editor and verify that none of the inputs contain unintended spaces, currency symbols, or non-numeric characters.

Solution 1Recommended

Convert Field Values Using JavaScript Functions

Force the PDF form to treat text field inputs as numeric values by explicitly parsing them in the custom calculation script.

By default, PDF form fields evaluate inputs as text strings. If you attempt to add these values together using a standard plus sign, the program simply joins the text together. By enforcing a numeric conversion within your script, you prevent this accidental concatenation.

1
Enter form editing mode

Open your PDF file in your editor and navigate to the Form Editing or Prepare Form mode to view interactive fields.

2
Access field properties

Right-click the target field where the calculation result will appear and select 'Properties' from the context menu.

3
Edit calculation script

Navigate to the 'Calculate' tab and choose 'Custom calculation script', then click the 'Edit' button.

4
Apply numeric conversion

Wrap your field value retrieval variables in a Number() or parseFloat() function. For example: var val1 = Number(this.getField('Text1').value);

5
Complete and save

Write out your addition formula (e.g., event.value = val1 + val2;) and click 'OK' or 'Close' to save the new properties.

Script Syntax Reminder: Always ensure there are no blank spaces in your variable names and that you handle empty fields correctly to avoid NaN (Not a Number) errors.
WPS PDF Editor

Easily Design and Calculate PDF Forms with WPS Office

WPS PDF Editor provides a comprehensive set of tools for creating interactive forms. You can easily define field properties, manage calculation scripts, and ensure your data behaves exactly as intended without wrestling with complex formatting.

  1. 1. Open PDF in WPS Office: Launch WPS Office and open the PDF form you wish to edit.
  2. 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to reveal interactive field controls.
  3. 3. Insert or select fields: Click on 'Text Field' to insert a new box, or simply double-click an existing field.
  4. 4. Set calculation properties: In the Properties window, use the 'Format' and 'Calculate' tabs to establish numeric rules and automated math functions.
Easily configure form fields for text, numbers, and dates with intuitive menus.Fully compatible with standard Adobe Acrobat PDF form formats and calculation scripts.Built-in simple calculation tools for seamless math operations without writing code.Lightweight software offering a user-friendly interface for professional PDF editing.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF form show NaN when calculating?

NaN stands for 'Not a Number'. This typically occurs if one of your calculation fields is left blank or contains non-numeric text. You can resolve this by adding a script condition to treat empty fields as a zero value.

Can I do basic addition in a PDF form without using JavaScript?

Yes, standard PDF editors allow you to use built-in functions. In the field properties under the Calculate tab, select 'Value is the sum (+) of the following fields' and pick the target fields, avoiding custom code entirely.

Do currency symbols interfere with PDF field calculations?

Yes. If a user manually types a currency symbol or a comma into an input field, the calculation script may process the entire input as text. It is best practice to set the field's Format category to 'Number' or 'Currency' in the properties, so the symbol is handled automatically by the software rather than the user's keystrokes.