PDF Editing Issues

How to Fix an Illegal Character Error in Acrobat JavaScript

Bushra ParveenBushra Parveen Nov 3, 2026 868 views

Question details

The user is encountering an 'illegal character' error when running an Adobe Acrobat form script due to the use of typographic (curly) quotation marks instead of standard straight quotation marks.

How to Fix an Illegal Character Error in Acrobat JavaScript
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
Writing or pasting JavaScript code for PDF form fields.
Observed behavior
The Acrobat JavaScript engine throws an 'illegal character' syntax error and fails to execute the form script properly.
Before you start

Check the text editor you used to write your JavaScript code, as standard word processors often auto-format quotation marks into unsupported characters.

Solution 1Recommended

Replace Typographic Quotes with Standard Straight Quotes

Manually correct the quotation marks in your Acrobat JavaScript editor to ensure the code executes without syntax errors.

JavaScript strictly requires standard straight quotation marks to define strings. Typographic or 'curly' quotes introduced by copying code from documents will trigger an illegal character error.

1
Open the JavaScript Editor

In Adobe Acrobat Pro, right-click the form field you are trying to edit, select 'Properties', and navigate to the 'Calculate' or 'Actions' tab to open the JavaScript editor.

2
Identify Curly Quotes

Look for typographic or curly quotation marks in your code, such as those surrounding your field names (e.g., this.getField(“JKP1”)).

3
Replace with Straight Quotes

Delete the curly quotes and type standard straight double quotes on your keyboard, changing the code to this.getField("JKP1"). Click 'OK' to save the script.

Replace Typographic Quotes with Standard Straight Quotes
Avoid Word Processors: Microsoft Word automatically converts standard straight quotes into curly quotes. Never use Word to write or temporarily store your JavaScript code.

Easily Manage PDF Forms with WPS Office

Avoid complex script errors and heavy software by using WPS Office's intuitive PDF tools. WPS Office provides a streamlined, user-friendly interface to create, edit, and fill out interactive PDF forms without the hassle.

  1. 1. Open the PDF File: Launch WPS Office and open your existing PDF form document.
  2. 2. Access the Form Tools: Navigate to the 'Form' tab on the top ribbon to access the suite of interactive form controls.
  3. 3. Add or Edit Fields: Select the desired field type (such as Text Field or Checkbox) and click on the document to place it. Adjust the properties in the side panel.
  4. 4. Save Your Changes: Once your form is set up, go to 'Menu' and click 'Save As' to export your interactive PDF.
Intuitive form editing interface without requiring complex JavaScript programming.Fully compatible with standard Adobe PDF formats and form fields.Lightweight, fast-loading alternative to heavy PDF editing software.Comprehensive built-in tools for adding text, checkboxes, drop-downs, and signatures.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Microsoft Word change my quotation marks?

Word has an 'AutoFormat' feature that automatically converts straight quotes to smart (curly) quotes for better typography. However, this feature breaks programming code which requires standard straight characters.

What is the correct quotation mark for JavaScript?

JavaScript requires standard straight double quotes (" ") or straight single quotes (' ') to define string literals. It does not recognize slanted, curly, or typographic quotation marks.

Can I disable smart quotes in Microsoft Word?

Yes, you can disable them in Word by navigating to File > Options > Proofing > AutoCorrect Options, and unchecking 'Straight quotes with smart quotes' under the 'AutoFormat As You Type' tab.

How do I open the JavaScript debugger in Adobe Acrobat?

You can open the debugger console in Acrobat Pro by pressing Ctrl+J on Windows or Cmd+J on Mac. This console allows you to view detailed error messages and troubleshoot your scripts.