PDF Editing Issues

How to Remove Underscores and Display Spaces in Acrobat Form Field Names

Rana GarciaRana Garcia Nov 3, 2026 869 views

Question details

The user wants to remove underscores and display spaces in PDF form drop-down labels without breaking the JavaScript used to populate related fields.

How to Remove Underscores and Display Spaces in Acrobat Form Field Names
Product
Adobe Acrobat PDF Forms
Device & OS
not provided
Scenario
Using JavaScript to populate related form fields based on drop-down selections where field labels need to contain spaces instead of underscores.
Observed behavior
The JavaScript fails to process field names containing spaces, forcing the use of underscores (e.g., Health_Plan instead of Health Plan) in the form labels.
Before you start

Ensure your PDF document is opened in 'Prepare Form' mode and you have access to the document's JavaScript editor or the specific drop-down field's custom calculation script.

Solution 1Recommended

Use Quoted Property Names in the JavaScript Object

Wrap field names that contain spaces in double quotation marks within your JavaScript object to ensure the script parses them correctly.

In JavaScript, object property names with spaces are perfectly valid, but they must be enclosed in quotes. By quoting the property names, you eliminate the syntax errors caused by spaces and avoid having to use underscores for your form's drop-down labels.

1
Open form editing mode

Open your PDF file and enter the 'Prepare Form' mode from the tools menu to access your interactive form fields.

2
Locate the JavaScript object

Right-click the drop-down field, select 'Properties', and navigate to the 'Format' or 'Calculate' tab to find the custom JavaScript you are using to populate fields.

3
Add double quotation marks

Wrap the field names that require spaces in double quotation marks. For example, change Health_Plan to "Health Plan": { "FurtherCredit": "HP-ABERDEEN_EM_EQUI", "Acct": "444444" }.

4
Update script references

Ensure that any subsequent references in your script match the exact quoted field names, including the spaces.

5
Preview and test the form

Exit 'Prepare Form' mode and test the drop-down menu to verify that 'Health Plan' displays properly with a space and successfully populates the related fields.

Use Quoted Property Names in the JavaScript Object
JavaScript Console Validation: Press Ctrl+J (Windows) or Cmd+J (Mac) to open the JavaScript debugger. This allows you to monitor the console for any syntax errors after modifying your code.
Efficient PDF Form Editing

Create and Manage PDF Forms with WPS Office

WPS Office provides comprehensive and user-friendly PDF editing tools. You can easily manage interactive form fields, edit text, and customize drop-down lists without needing complex JavaScript troubleshooting.

  1. 1. Open your PDF file: Launch WPS Office and open the PDF form you need to modify.
  2. 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to access all interactive form editing features.
  3. 3. Edit drop-down properties: Double-click on any drop-down field to quickly edit its properties, including item names and export values, directly from the interface.
  4. 4. Save and export: Click 'Save' to preserve your interactive form field updates seamlessly.
Easily add, edit, and manage interactive PDF form fields.Fully compatible with standard Adobe PDF forms and formatting.Lightweight alternative with an intuitive and familiar user interface.Seamlessly merge, convert, sign, and edit PDF documents in one app.
microsoft office alternative - wps office

Frequently Asked Questions

Why does JavaScript fail when PDF form field names have spaces?

In standard JavaScript syntax, object keys or property names that contain spaces or special characters must be wrapped in quotes (e.g., "Retirement Plan"). If unquoted, the JavaScript engine interprets the space as a break in the code, resulting in a syntax error.

Do internal PDF form field names appear to the end user?

Internal form field names generally do not appear on the final document when a user is filling it out. However, if you are using these names as the actual display text or 'Item Names' in a drop-down list, the user will see exactly what is written, which is why formatting with spaces instead of underscores is important.

How do I access the JavaScript debugger in PDF editors?

In advanced PDF editors like Acrobat, you can open the JavaScript console by pressing Ctrl+J on Windows or Cmd+J on a Mac. This console displays code execution errors and helps you troubleshoot why a drop-down population script might be failing.