PDF Editing Issues

Fix Illegal Character Syntax Errors in Acrobat PDF Form JavaScript

John WilsonJohn Wilson Oct 28, 2026 869 views

Question details

The user encounters a 'SyntaxError: illegal character' when running a custom calculation script in an Acrobat PDF form.

Fixing Illegal Character Syntax Errors in Acrobat PDF Form JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Writing or executing custom JavaScript calculation equations for specific PDF form fields.
Observed behavior
The script fails and throws a syntax error due to the use of the '#' symbol in variable declarations and improper syntax for the Math.min function.
Before you start

Ensure you have editing permissions for the PDF form fields and open your document in the Acrobat form preparation mode to access the calculation properties.

Solution 1Recommended

Correct Variable Names and Math Function Syntax

Resolve the illegal character syntax error by updating JavaScript variable names to remove special symbols and properly formatting the math equations.

Acrobat PDF form calculations rely on standard JavaScript rules. Using invalid characters like '#' in variable declarations or using improper casing and brackets for built-in functions will immediately cause the script to fail and throw a syntax error.

1
Remove illegal characters from variable names

Locate variables such as `Owner_#1_Loan_Period` in your calculation script. Delete the `#` symbol and rewrite them using standard camelCase formatting, such as `owner1LoanPeriod` and `owner1Age`.

2
Correct case-sensitivity for the Math object

Find instances of `math.min` and change them to `Math.min`. Standard JavaScript requires exact casing for built-in objects, and 'Math' must always be capitalized.

3
Use parentheses for function arguments

Replace square brackets with standard parentheses in your math equations. For example, update the script to read `event.value = Math.min(65 - owner1Age, 30);`.

4
Extract field values directly (Alternative)

Instead of declaring intermediate variables, you can read the form fields directly by inserting `this.getField("YourFieldName").value` directly into your calculation logic.

Correct Variable Names and Math Function Syntax
Syntax check: Test your custom calculation script in the Acrobat JavaScript console before saving to ensure there are no remaining typos or syntax warnings.
Easy PDF Form Management

Edit and Manage PDF Forms Seamlessly with WPS Office

Simplify your workflow by using the built-in PDF tools in WPS Office. You can easily fill out, edit, and manage standard PDF forms without worrying about complex JavaScript syntax errors.

  1. 1. Open WPS Office: Launch WPS Office on your computer and select the 'PDF' module from the main dashboard.
  2. 2. Load your PDF Form: Click 'Open' and browse your files to select the PDF form document you need to work on.
  3. 3. Fill or Edit Fields: Navigate to the Form tab or simply click on the highlighted form fields to input your data, check boxes, or select dropdown options directly.
  4. 4. Save the Document: Click 'Save' or 'Export' to finalize your document and preserve all filled form data securely.
Intuitive PDF form filling and editing interfaceFully compatible with standard Adobe PDF formsLightweight, fast, and feature-rich PDF toolsetFree to use across multiple platforms
microsoft office alternative - wps office

Frequently Asked Questions

What are the naming rules for JavaScript variables in PDF forms?

JavaScript variable names must begin with a letter, an underscore (_), or a dollar sign ($). They cannot contain spaces or special characters like #, %, or @. It is recommended to use camelCase, such as 'loanPeriod', for readability.

Why does Math.min return a syntax error in my script?

This usually happens due to incorrect casing, such as typing 'math.min' instead of 'Math.min', or using square brackets instead of parentheses for the arguments. It must be written exactly as Math.min(value1, value2).

How do I reference another field's value in Acrobat JavaScript?

You can retrieve the value of any form field by using the method this.getField('ExactFieldName').value in your custom calculation script, ensuring the exact field name is enclosed in quotes.