PDF Editing Issues

How to Display a Full Name Without Extra Spaces in Acrobat PDF Forms

Emma BrownEmma Brown Nov 5, 2026 869 views

Question details

The user wants to combine multiple text fields (First Name, Middle Name, Last Name, Suffix) into a single Full Name field dynamically, ensuring no double spaces appear if a field like Middle Name is left blank.

How to Display a Full Name Without Extra Spaces in Acrobat PDF Forms
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating or editing a dynamic PDF form where a complete name needs to be auto-populated based on individual text field inputs.
Observed behavior
Standard string concatenation scripts leave an extra blank space when an optional field is empty, resulting in an unpolished appearance in the final Full Name field.
Before you start

Ensure your PDF form already contains distinct text fields for the first name, middle name, last name, and suffix, and note their exact field names as JavaScript is case-sensitive.

Solution 1Recommended

Use Array Push and Join in Custom Calculation Script

This method pushes only non-empty name fields into a JavaScript array and joins them with a single space, automatically preventing double spaces.

Using a standard string concatenation like combining values with a plus sign results in double spaces if a field is blank. Leveraging an array allows the script to filter out empty strings before joining the components together.

1
Open Prepare Form Mode

Open your PDF document in Adobe Acrobat, navigate to the Tools menu, and select Prepare Form to enter the form editing mode.

2
Access Target Field Properties

Right-click on the destination text field where you want the full name to appear, select Properties, and navigate to the Calculate tab.

3
Enter the JavaScript Code

Select 'Custom calculation script' and click the Edit button. Enter the code to declare your variables using getField("Field Name").valueAsString. Create an empty array, use if statements to push variables to the array only if they are not equal to "", and set event.value = arrayName.join(" ");.

4
Apply and Test

Click OK to save the script, then close the Properties dialog. Click Preview at the top right to test your form by entering names with and without middle names or suffixes to confirm no extra spaces are generated.

Use Array Push and Join in Custom Calculation Script
Exact Match Required: Make sure the field names inside your getField() functions exactly match the names of the text fields in your PDF form, including spaces and capitalization.
Free Microsoft Office alternative

Need a simpler way to manage documents and PDFs? Try WPS Office

If dealing with complex PDF JavaScript calculations and expensive software is slowing you down, WPS Office provides a lightweight, all-in-one suite to easily view, edit, and manage your PDFs, Word documents, and spreadsheets without the hassle.

Fully compatible with Microsoft Word, Excel, PowerPoint, and standard PDF formats.Intuitive PDF editing tools to modify text, insert images, and fill out forms effortlessly.Lightweight software architecture that runs smoothly on Windows, Mac, Linux, and mobile devices.Free core features to cover your daily document management and viewing needs.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my PDF form show a double space when the middle name is empty?

If you use basic string concatenation, the script adds the hardcoded space characters regardless of whether the middle name contains text. Using an array to check for empty fields before joining them resolves this issue entirely.

Can I apply this JavaScript method to combine addresses in Acrobat?

Yes. You can use the exact same array push and join method to combine street, city, state, and zip code fields into a single block, skipping any blank address lines by only pushing non-empty values.

Where do I add custom calculation scripts in Adobe Acrobat?

In the Prepare Form tool, double-click the target field to open its Properties dialog. Navigate to the Calculate tab, choose 'Custom calculation script' at the bottom, and click the Edit button to paste your JavaScript code.