PDF Editing Issues

Fix an Acrobat Combo Box Script Syntax Error

Huda QurayshiHuda Qurayshi Nov 18, 2026 869 views

Question details

The user needs to resolve a syntax error in a JavaScript script for an Acrobat PDF form combo box.

Fix a Syntax Error in an Acrobat Combo Box Script
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating a PDF form with multiple drop-down fields and a combo box script.
Observed behavior
The combo box script reports a syntax error associated with a field or variable name.
Before you start

Open the PDF in Adobe Acrobat and locate the combo box and its JavaScript in Prepare a Form. Check whether Pers.-Nr is used as a JavaScript variable, a form field name, or both.

Solution 1Recommended

Rename the problematic field or JavaScript variable

Replace Pers.-Nr with PersNr and update the script references to avoid punctuation in the identifier.

JavaScript identifiers cannot contain a hyphen or a period. A field name can contain punctuation when it is passed as a quoted string, but using a simple name can make references easier to manage.

1
Open the form editor

In Acrobat, open the PDF and select Prepare a Form from the tools or All tools menu.

2
Rename the field if needed

Select the affected field, open its Properties, and change the Name on the General tab from Pers.-Nr to PersNr.

3
Update the script

Open the combo box Properties and find the script on the relevant tab. Replace any variable named Pers.-Nr with PersNr. If you renamed the field, update calls such as this.getField("Pers.-Nr") to this.getField("PersNr").

4
Check other references and test

Review scripts in the other form fields for references to the old name, update them, and then use Preview in Prepare a Form to test the drop-down.

Rename the problematic field or JavaScript variable
Quoted field names are different: A call such as this.getField("Pers.-Nr") is valid JavaScript because the field name is a quoted string. If the field name is not changed, leave that string unchanged and check the actual error location in the script.
Free Microsoft Office alternative

Work with PDFs and Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and support for common Microsoft Office formats, making it easy to move existing documents into your workflow. It does not fix an Acrobat-specific JavaScript error; use Acrobat to edit and test that script.

Open and work with PDF documents alongside other filesCompatible with Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface for everyday document tasksMove existing Office files into a lightweight workspace
microsoft office alternative - wps office

Frequently Asked Questions

Why does Pers.-Nr cause a JavaScript error?

A period and a hyphen cannot be part of a JavaScript variable identifier. Use a name such as PersNr, or Pers_Nr, and update its references in the script.

Can an Acrobat field name contain a hyphen?

Yes. A field name with a hyphen can be passed as a quoted string, for example this.getField("Pers.-Nr"). Renaming the field is optional if the quoted name is not the cause of the error.

Where do I change a field name in Acrobat?

Open Prepare a Form, select the field, and open its Properties. Change the Name on the General tab, then update scripts that refer to the old name.

How can I check whether the combo box works after editing?

In Prepare a Form, select Preview and try the drop-down. Also test any other fields whose scripts reference the renamed field.