Automatically Combine Name Fields in an Adobe Acrobat Form
Question details
Create a calculated Full Name field that combines separate name fields automatically.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form collects a first name, middle initial, last name, and optional suffix in separate fields.
- Observed behavior
- The Full Name field should update when a source field changes, adding spaces and a comma before the suffix only when needed.
Open the PDF in Adobe Acrobat and confirm that the first name, middle initial, last name, suffix, and Full Name fields exist. Check their exact field names in Prepare a form; the script must use those names.
Add a custom calculation script to the Full Name field
Use this method to update the Full Name field automatically as users complete the separate name fields.
In Acrobat, open the PDF and select All tools > Prepare a form. Locate the Full Name text field.
Double-click the Full Name field to open its properties. Select the Calculate tab, choose Custom calculation script, and click Edit.
Paste this script into the editor. Replace FirstName, MiddleInitial, LastName, and Suffix with the exact names of your source fields if they differ: function fieldText(name) { var field = this.getField(name); return field ? String(field.value).replace(/^\s+|\s+$/g, "") : ""; } var first = fieldText("FirstName"); var middle = fieldText("MiddleInitial"); var last = fieldText("LastName"); var suffix = fieldText("Suffix"); var parts = []; if (first) parts.push(first); if (middle) parts.push(middle); if (last) parts.push(last); var fullName = parts.join(" "); if (suffix) fullName += (fullName ? ", " : "") + suffix; event.value = fullName;
Close the script editor and field properties, save the PDF, and exit form editing. Enter and change values in the name fields to confirm that Full Name updates, including when the middle initial or suffix is blank.

Use WPS Office for Everyday PDF and Document Work
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. Its format compatibility makes it easy to move existing documents into WPS, but it does not replace Acrobat's custom calculation script for this form.

Frequently Asked Questions
Where do I put the name-combining script in Acrobat?
In Prepare a form, open the Full Name field properties, select Calculate, and choose Custom calculation script. Click Edit and paste the script there, not in one of the source fields.
What happens if the middle initial or suffix is blank?
The script skips blank fields. It joins the available name parts with spaces and adds a comma before the suffix only when both the suffix and another name part are present.
Why is the Full Name field not updating?
Check that the names in getField match the actual field names in Prepare a form. Also confirm that JavaScript and automatic form calculations are enabled in Acrobat's preferences, and test the PDF in Acrobat rather than a viewer with limited JavaScript support.
Will the script add a period after the middle initial?
No. The script uses the middle initial as entered. Include a period in the source field if you want it to appear in the Full Name.




