PDF Editing Issues

Combine PDF Form Fields Without a Blank Middle Initial in Adobe Acrobat

Ayan MasoodAyan Masood Nov 24, 2026 869 views

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.

Combine PDF Form Fields Without a Blank Middle Initial in Adobe Acrobat
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the form editor

In Adobe Acrobat, open the PDF and select All tools > Prepare a form.

2
Open the destination field

Double-click the FullName field to open its properties, then select the Calculate tab.

3
Enter the calculation

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;

4
Test both cases

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.

Add a Custom Calculation Script to the FullName Field
Match field names exactly: The names inside getField must match the PDF form field names. This script tests for an empty middle-initial value; it does not treat a space entered in that field as empty.
Free Microsoft Office alternative

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.

Open and work with PDF documents alongside other files.Compatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTX.Use a familiar interface for everyday document tasks.Keep common document tools together in one lightweight office suite.
microsoft office alternative - wps office

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.