Fix Syntax and Quote Errors in Adobe Acrobat JavaScript Calculations
Question details
The user is encountering syntax or illegal character errors when executing custom JavaScript to calculate, sum, and divide checkbox values in a PDF form.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Adding custom JavaScript calculations to a PDF form to perform math operations based on multiple field values.
- Observed behavior
- The JavaScript fails to execute, returning an 'illegal character' or 'syntax error' message instead of the calculated result.
Ensure you have access to the PDF form's editing mode and can open the JavaScript editor for the specific calculation field.
Replace Smart Quotes and Balance Parentheses
The most common cause of these errors is pasting code from a word processor that uses formatted curly quotes instead of standard straight quotes.
When you copy and paste JavaScript code from Microsoft Word or rich-text web pages, standard straight quotes (") are often automatically converted into typographic smart quotes (“ ”). The Adobe Acrobat JavaScript engine does not recognize these formatted quotes, resulting in an 'illegal character' error.
Additionally, complex mathematical formulas involving addition and division require perfectly balanced parentheses to ensure the order of operations is calculated correctly.
Open your PDF document in Adobe Acrobat and select the Prepare Form tool from the right-hand pane.
Right-click the specific text field that contains your calculation error and select Properties from the context menu.
Navigate to the Calculate tab, select 'Custom calculation script', and click the Edit button.
Carefully scan your script (especially the getField functions) and manually delete any curly quotes (“ ”), replacing them with standard straight quotes (" ") using your keyboard.
Review the mathematical expression at the end of your script (e.g., event.value = (v1 + v2 + v3) / 4;) to ensure every opening parenthesis has a matching closing parenthesis.
Click OK to save your updated script, close the properties dialog, and test your form checkboxes to verify the calculation works without syntax errors.

Manage and Fill PDF Forms Easily with WPS Office
Need a simpler way to handle interactive PDF documents and forms? WPS Office offers a comprehensive, lightweight PDF editor that allows you to view, fill, and manage PDF files seamlessly across all your devices.
- 1. Download WPS Office: Download and install the free WPS Office suite from the official website.
- 2. Open your PDF: Launch the WPS PDF tool and open your interactive PDF form.
- 3. Interact with forms: Use the built-in form filling features to easily check boxes, input text, and manage your document data.

Frequently Asked Questions
Why do smart quotes cause errors in Adobe Acrobat JavaScript?
JavaScript syntax strictly requires standard straight ASCII quotes (" or ') to identify strings. Typographic smart quotes (“ ”) are interpreted as unrecognized special characters by the compiler, leading directly to 'illegal character' syntax errors.
How do I test my PDF JavaScript calculation without closing the editor?
You can use the JavaScript Debugger in Adobe Acrobat by pressing Ctrl+J (Windows) or Cmd+J (Mac). This allows you to run and test snippets of code in the console to pinpoint exactly which line contains the syntax error.
Will my PDF form calculations work on mobile devices?
Custom JavaScript calculations in PDF forms may not be fully supported by default mobile PDF viewers or web browsers. It is recommended that users open the interactive form in dedicated PDF software on a desktop for full script compatibility.




