Combine Name Fields in an Adobe Acrobat Form
Question details
Combine four name fields in an Acrobat form, with conditional punctuation for the middle initial and suffix.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form needs a calculated full-name field based on separate first name, middle initial, last name, and suffix fields.
- Observed behavior
- The full name should include a period after a populated middle initial and a comma before a populated suffix, without extra spaces or punctuation for empty fields.
Open the PDF in an Acrobat version that supports editing form fields. Check the exact names of the four source fields and create a separate text field for the combined name if one does not already exist.
Calculate the Full Name with Acrobat JavaScript
Use a custom calculation script to combine the fields and add punctuation only when the relevant values are present.
Open the PDF in Adobe Acrobat and select All tools > Prepare a form.
Select the text field that will display the combined name, open its Properties, and select the Calculate tab.
Select Custom calculation script, click Edit, and paste the following script: var fn = this.getField("First Name").valueAsString.trim(); var mn = this.getField("Middle Initial").valueAsString.trim(); var ln = this.getField("Last Name").valueAsString.trim(); var sf = this.getField("Suffix").valueAsString.trim(); var parts = []; if (fn) parts.push(fn); if (mn) parts.push(mn.replace(/\.$/, "") + "."); if (ln) parts.push(ln); var name = parts.join(" "); if (sf) name += (name ? ", " : "") + sf; event.value = name;
Confirm the script, close the field properties, and save the PDF. Enter values in the source fields, then test again with the middle initial and suffix left blank.

Work with PDF Forms and Documents in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. Its format compatibility makes it easy to move existing files into your workflow, though it does not replace Acrobat's custom form calculation setup.

Frequently Asked Questions
What happens if the middle initial or suffix is blank?
The script omits the period for a blank middle initial and the comma for a blank suffix. It also joins populated name parts without extra spaces.
Where do I enter the JavaScript in Acrobat?
In All tools > Prepare a form, open the combined-name text field's Properties. On the Calculate tab, select Custom calculation script and click Edit.
Why does the script not find one of my fields?
The names in getField() must exactly match the source field names in your PDF. Check each field's name in Prepare a form and update the script accordingly.
Will the middle initial get two periods if one is already entered?
No. The example removes one trailing period from the middle initial before adding a period to the combined name.




