How to Populate a Full Name PDF Field from First, Middle, and Last Names
Question details
The user wants to combine data from separate First Name, Middle Initial, and Last Name fields into a single Full Name field in a PDF, handling cases where the middle initial is blank.

- Product
- Device & OS
- not provided
- Scenario
- Creating or editing a fillable PDF form that requires a combined full name generated from separate name input fields.
- Observed behavior
- The user needs to automatically merge text from three separate fields into one target field, ensuring proper spacing even if the middle initial field is left empty.
Ensure you have a PDF editor that supports advanced form field editing and JavaScript calculations, and verify that your separate name fields are already created and correctly named.
Use a Custom Calculation Script to Combine Name Fields
Add a JavaScript calculation to the target Full Name field to automatically concatenate the first, middle, and last names while cleanly handling empty middle initials.
This method uses a simple script to read the values of the individual name fields and merge them. It checks if the middle initial exists to prevent double spaces in the final combined name.
Open the PDF in form editing mode, right-click the target 'Full Name' field, and select 'Properties'.
In the Properties dialog box, go to the 'Calculate' tab and select the 'Custom calculation script' option.
Click 'Edit' and input a script that reads the First Name, Middle Initial, and Last Name fields using the valueAsString method.
Within the script, write a conditional statement: if the middle initial is empty, combine only the first and last names with a single space. Otherwise, combine all three fields with spaces.
Click 'OK' to save the script, close the properties dialog, and type test names into your fields to verify the output.

Mirror Fields Using Identical Names
If you do not need the names combined into one field but just want the separate names to duplicate automatically on another page, use identical field names.
Create and Edit Advanced PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that lets you easily create fillable forms, adjust field properties, and manage document layouts without the need for complex desktop software.
- 1. Open Your PDF: Launch WPS Office, go to the PDF tab, and open your document in the PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access various interactive form field tools.
- 3. Insert Text Fields: Click the 'Text Field' button to draw new input boxes for your First, Middle, and Last names.
- 4. Adjust Properties: Right-click any field and select 'Properties' to customize its behavior, formatting, or calculations.

Frequently Asked Questions
Why are there double spaces in my combined PDF field?
Double spaces occur if the calculation script blindly adds a space before and after an empty middle initial field. To fix this, use a conditional 'if' statement in your JavaScript to check if the middle initial field is empty before adding it and its surrounding spaces to the final string.
Do I need to know JavaScript to create PDF forms?
For basic text input, checkboxes, and mirrored fields (where duplicate field names share the same data), no coding is required. However, for advanced custom actions like combining separate text fields into one formatted field, basic JavaScript is necessary.
How do I make a PDF field calculate automatically?
Open the target field's Properties, go to the Calculate tab, and choose your preferred calculation method. Make sure that your PDF editor's global preferences have 'Automatically calculate field values' enabled so the form updates in real-time.




