PDF Editing Issues

Fix Adobe Acrobat PDF Form JavaScript Errors from Spaces in Property Names

Muhammad TalhaMuhammad Talha Nov 19, 2026 868 views

Question details

Use a combo-box value containing spaces as a JavaScript object property in an Acrobat PDF form without a syntax error.

Fix Acrobat PDF Form JavaScript Errors from Spaces in Property Names
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A PDF form script uses a department selected in a combo box to look up address information in a JavaScript object.
Observed behavior
An unquoted property name containing spaces can trigger a missing-colon syntax error.
Before you start

Open the PDF in Adobe Acrobat and identify the combo-box field name and the script that defines or accesses the object. Check the combo box's export values, since the script must use the value returned by the field.

Solution 1Recommended

Quote property names and look up the combo-box value with brackets

Use this fix when a JavaScript object key contains spaces or comes from a combo-box selection.

1
Open the form script

In Acrobat, open Prepare a form, select the relevant field, and open its Properties. Find the JavaScript under the field's Actions, Validate, or Calculate tab and select Edit.

2
Quote the property name

In the script editor, put the entire property name in quotation marks when defining the object: var DeptData = {"CSS Frogner": {adresse: "Frederik Stangs Gate 4", poststed: "0272 Oslo"}};

3
Use bracket notation for the lookup

In the same script, or wherever DeptData is available, retrieve the selection with var key = this.getField("Department").valueAsString; and look it up with var dept = DeptData[key];. Replace Department with the actual combo-box field name.

4
Save and test the form

Close the script editor, save the PDF, and select the corresponding combo-box option. Confirm that its returned value exactly matches the quoted object key, including spaces and capitalization.

Quote property names and look up the combo-box value with brackets
Check the selected value: If an option has an export value, Acrobat may return that value rather than the displayed label. Use the returned value as the object key, and check that dept is defined before accessing dept.adresse or dept.poststed.
Free Microsoft Office alternative

Work with PDF and Office files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Microsoft Office files. It can help you migrate everyday document workflows, but it does not fix JavaScript in an Acrobat form.

Open and annotate PDF documents alongside other office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for moving everyday document workflows to WPSFree, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does a property name with spaces cause a missing-colon error?

In an object literal, a property name containing spaces must be quoted. Write {"CSS Frogner": value}, not {CSS Frogner: value}.

How do I use a combo-box selection to access an object property?

Read the field value with this.getField("Department").valueAsString, replacing Department with your field name. Then use bracket notation, such as DeptData[key], to look up that value.

Why does the lookup return undefined after I fix the syntax?

Check that the combo box's returned value exactly matches an object key, including capitalization and spaces. If the option has an export value, use that value as the key rather than assuming the displayed label is returned.

Where can I edit a form field's JavaScript in Acrobat?

Open Prepare a form, select the field, and open Properties. Depending on the script, look under Actions, Validate, or Calculate and select Edit.