How to Remove Underscores and Display Spaces in Acrobat Form Field Names
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.

- 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.
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.
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.
Open your PDF file and enter the 'Prepare Form' mode from the tools menu to access your interactive form fields.
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.
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" }.
Ensure that any subsequent references in your script match the exact quoted field names, including the spaces.
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.

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. Open your PDF file: Launch WPS Office and open the PDF form you need to modify.
- 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to access all interactive form editing features.
- 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. Save and export: Click 'Save' to preserve your interactive form field updates seamlessly.

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.




