PDF Editing Issues

How to Combine Three PDF Form Fields into One Field

Anum MushtaqAnum Mushtaq Nov 3, 2026 869 views

Question details

The user needs a method to merge the data entered in three separate PDF form fields into one single target form field.

How to Combine Three PDF Form Fields into One Field
Product
PDF Editor
Device & OS
not provided
Scenario
Creating or formatting an interactive PDF form where a full name needs to be aggregated automatically from separate First, Middle, and Last name fields.
Observed behavior
A calculation or script is required to concatenate the text strings from three source fields into one destination field, while properly handling blank values.
Before you start

Ensure your PDF editor supports JavaScript for interactive form fields (such as Adobe Acrobat Pro) and that the source fields (e.g., First1, Middle1, Last1) are already created and named exactly as they will appear in your script.

Solution 1Recommended

Add a Custom JavaScript Calculation to the Target Field

Use a custom calculation script in the destination field's properties to automatically fetch, format, and combine the values of the source fields.

By using a small JavaScript snippet in the target field, the PDF will automatically read the text typed into the source fields and join them together with spaces. Using the valueAsString property is crucial here, as it ensures that if a user skips a field (like a middle name), it won't break the script or output 'null'.

1
Open Field Properties

Open your PDF in Form Preparation mode. Right-click the destination field (e.g., 'Name1') and select 'Properties' from the context menu.

2
Navigate to the Calculate Tab

In the Field Properties dialog box, click on the 'Calculate' tab to view the calculation options for this specific field.

3
Enter the Custom Script

Select 'Custom calculation script' and click the 'Edit' button. Paste the following code: var values = []; values.push(this.getField("First1").valueAsString); values.push(this.getField("Middle1").valueAsString); values.push(this.getField("Last1").valueAsString); event.value = values.join(" ");

4
Save and Test

Click 'OK' to save the script, then close the Properties window. Exit the form editing mode and type test data into the First1, Middle1, and Last1 fields to see them instantly combine in the Name1 field.

Add a Custom JavaScript Calculation to the Target Field
Handling Blank Fields: Using the .valueAsString property perfectly handles empty form fields by treating them as blank text, which prevents unsightly 'null' text strings from appearing in your final combined field.
Powerful PDF Form Management

Create and Edit Interactive PDF Forms with WPS Office

WPS PDF provides a comprehensive suite of tools for creating, editing, and managing interactive PDF forms. Easily add text fields, checkboxes, and buttons to your documents without the need for expensive, heavy software.

  1. 1. Open WPS PDF: Download and launch WPS Office, then open your PDF document using the dedicated PDF tab.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal all interactive form creation tools.
  3. 3. Add Form Fields: Select the 'Text Field' or other control icons to draw and place interactive fields directly onto your document layout.
  4. 4. Save and Distribute: Save your newly created interactive PDF. The form fields will remain perfectly compatible with any standard PDF reader your recipients use.
Easily insert and manage interactive text fields, checkboxes, and drop-down listsHighly compatible with standard Adobe Acrobat PDF form formatsLightweight, all-in-one suite that includes a built-in PDF reader, editor, and converterCross-platform support for seamless editing on Windows, Mac, and mobile devices
microsoft office alternative - wps office

Frequently Asked Questions

Why does 'null' appear in my combined field when a source field is left empty?

This usually happens if you use the standard .value property on an empty field. Modifying your script to use .valueAsString instead ensures that empty fields are treated as blank text strings rather than a null object.

Can I combine more than three form fields using this custom script?

Yes. You can combine as many fields as you need by simply adding additional lines of code (e.g., values.push(this.getField("YourFieldName").valueAsString);) for each new source field before the final join command.

Will the combined field update automatically if a user goes back and changes their first name?

Yes, PDF calculation scripts are triggered automatically in real-time whenever the values of the referenced source fields are modified or updated.