How to Fix an Illegal Character Error in Acrobat JavaScript
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.

- 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.
Check the text editor you used to write your JavaScript code, as standard word processors often auto-format quotation marks into unsupported characters.
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.
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.
Look for typographic or curly quotation marks in your code, such as those surrounding your field names (e.g., this.getField(“JKP1”)).
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.

Write Scripts in a Dedicated Code Editor
Prevent auto-formatting issues by drafting your JavaScript code in a plain text or code editor before pasting it into Acrobat.
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. Open the PDF File: Launch WPS Office and open your existing PDF form document.
- 2. Access the Form Tools: Navigate to the 'Form' tab on the top ribbon to access the suite of interactive form controls.
- 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. Save Your Changes: Once your form is set up, go to 'Menu' and click 'Save As' to export your interactive PDF.

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.




