PDF Editing Issues

Combine PDF Form Fields in Adobe Acrobat Without a Trailing And

Aamir Naveed AkramAamir Naveed Akram Nov 25, 2026 868 views

Question details

Combine two PDF form name fields while displaying “and” only when both fields contain a name.

Combine PDF Form Fields in Adobe Acrobat Without a Trailing And
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
A calculated PDF form field combines two defendant name fields.
Observed behavior
The calculated field displays an unnecessary trailing “and” when the second name field is empty.
Before you start

Open the PDF in a version of Adobe Acrobat that can edit form fields. Check the exact names of the two source fields in Prepare a Form, because the script must match them.

Solution 1Recommended

Use a Custom Calculation Script to Join Nonempty Name Fields

Add nonempty names to a list and join them with “and” in the calculated field.

1
Open the form editor

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

2
Open the calculated field properties

Double-click the field that should display the combined names, then select the Calculate tab.

3
Add the script

Select Custom calculation script, click Edit, and enter: var names = []; var name1 = this.getField("Defendant1 Name").valueAsString; if (name1 != "") names.push(name1); var name2 = this.getField("Defendant2 Name").valueAsString; if (name2 != "") names.push(name2); event.value = names.join(" and ");

4
Confirm and test

Click OK to save the script, close the field properties, and preview the form. Enter both names, then clear either name to verify that “and” appears only between two nonempty values.

Use a Custom Calculation Script to Join Nonempty Name Fields
Match the field names: Replace “Defendant1 Name” and “Defendant2 Name” in the script if your source fields use different names. The script treats a field containing only spaces as nonempty.
Free Microsoft Office alternative

Work With PDFs and Office Files in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with Office files and PDFs. It can help you move between document formats, but it does not replace Adobe Acrobat for configuring this custom calculation script; test scripted forms in your intended PDF viewer.

Open and review PDF documents alongside other office files.Work with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTX.Use a familiar interface to make migration from Microsoft Office easier.Keep common document tools together in a lightweight office suite.
QA img-9

Frequently Asked Questions

What happens if only one name field is filled in?

The calculated field displays that name without “and.” The script adds only nonempty values to the list before joining them.

Where do I find the exact names of my PDF form fields?

In Adobe Acrobat, open All tools > Prepare a form and check the field names in the form editor. Use those exact names inside the getField calls.

Why does the result still include an unwanted separator?

Check whether a source field contains spaces rather than being truly empty. The supplied script checks for an empty string, so spaces count as a value.

Will the calculation work in every PDF viewer?

Not necessarily. PDF viewers differ in their support for form JavaScript and calculations. Test the saved form in the viewer your recipients will use.