PDF Editing Issues

Combine Name Fields in an Adobe Acrobat Form

Huda QurayshiHuda Qurayshi Nov 24, 2026 869 views

Question details

Combine four name fields in an Acrobat form, with conditional punctuation for the middle initial and suffix.

Combine Name Fields in an Adobe Acrobat Form
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the form editor

Open the PDF in Adobe Acrobat and select All tools > Prepare a form.

2
Open the output field properties

Select the text field that will display the combined name, open its Properties, and select the Calculate tab.

3
Add the calculation script

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;

4
Save and test the form

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.

Calculate the Full Name with Acrobat JavaScript
Match the field names: Replace the names in getField() with the exact names used in your form. The output field must be separate from the four source fields.
Free Microsoft Office alternative

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.

Open PDF forms and review combined-name fieldsCompatible with Microsoft Word DOCX and other common Office formatsFamiliar interface for working with documents and PDFsFree and lightweight for everyday office tasks
microsoft office alternative - wps office

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.