Combine PDF Form Fields Without a Blank Middle Initial in Adobe Acrobat
Question details
Combine first name, middle initial, and last name fields into a FullName field without an extra space when the middle initial is blank.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form needs a calculated full name using values entered in separate form fields.
- Observed behavior
- The FullName field should include the middle initial only when it is present, with a single space between included name parts.
Open the PDF in a version of Adobe Acrobat that can edit form fields. Check that the form has fields named FirstName, MiddleInitial, LastName, and FullName, or substitute your actual field names in the script.
Add a Custom Calculation Script to the FullName Field
Use an Acrobat form calculation to omit the middle initial and its preceding space when the field is blank.
In Adobe Acrobat, open the PDF and select All tools > Prepare a form.
Double-click the FullName field to open its properties, then select the Calculate tab.
Select Custom calculation script, click Edit, and enter: var firstName = this.getField("FirstName").valueAsString; var middleInitial = this.getField("MiddleInitial").valueAsString; var lastName = this.getField("LastName").valueAsString; if (middleInitial == "") event.value = firstName + " " + lastName; else event.value = firstName + " " + middleInitial + " " + lastName;
Close the field properties, exit form editing, and enter a first and last name. Check FullName with MiddleInitial blank and again with an initial entered, then save the PDF.

Work With PDFs and Office Files in WPS Office
WPS Office is a free, lightweight alternative for everyday document work, with a familiar interface and compatibility that makes moving between Office files easier. It does not replace the Acrobat-specific calculation script described above.

Frequently Asked Questions
Which field should contain the calculation script?
Place it in the FullName field's Properties > Calculate > Custom calculation script. The script reads the three source fields and writes the result to event.value.
Why is there an extra space when the middle initial is blank?
A formula that always adds spaces around MiddleInitial leaves an extra space when that field is empty. Test whether its value equals an empty string and omit the initial and its space in that case.
What if my form uses different field names?
In Prepare a form, check each field's name in its properties. Replace FirstName, MiddleInitial, and LastName inside the script's getField calls with the corresponding names from your PDF.
Why doesn't the FullName field update?
Check that the script is in FullName's Calculate tab and that the source field names match. Also check Acrobat's Preferences for enabled JavaScript and automatic form field calculations.




