Skip to main content
johnnyZ
Inspiring
April 9, 2023
Answered

Combining 2 Fields ("First Name" and "Last Name") into ("Full Name")

  • April 9, 2023
  • 2 replies
  • 1227 views

I found this script:

event.value = this.getField("First Name").valueAsString + " " + this.getField("Last Name").valueAsString;

 

Problem is, if you go back and change the names in the "First Name" field, and "Last Name" field, it doesn't update the "Full Name" field.

Oh, By the way, I'm using Adobe Acrobat 9 Standard.

Also, does anyone know if there is still a newer version with a "one time" fee rather than a subscription?

This topic has been closed for replies.
Correct answer johnnyZ

Thank you, Nesa, I tried the script under the "Format" Tab and under the "Validate" Tab,

but I never tried it under the "Calculate" Tab.  YOUR SUGGISTION WORKS GREAT !!!

One more question (if you don't mind): What if the Person's Name has a Middle Initial?

event.value = this.getField("First Name").valueAsString + " " + this.getField("Middle Initial").valueAsString + " " + this.getField("Last Name").valueAsString;

But, if there is "No" Middle Initial, there will be 2 spaces between the First and Last Name

Similarly, I have a "Suffix" field, (ex. John Q Public, Sr.)

I'd like a comma if there IS a suffix, but NO comma if there is no suffix.

Is this possible?

Sorry, I should have included this with my initial question of First and Last Name.

2 replies

Nesa Nurani
Community Expert
Community Expert
April 10, 2023

Use script under 'Calculate' tab as 'Custom calculation script' in a "Full Name" field.

johnnyZ
johnnyZAuthorCorrect answer
Inspiring
April 10, 2023

Thank you, Nesa, I tried the script under the "Format" Tab and under the "Validate" Tab,

but I never tried it under the "Calculate" Tab.  YOUR SUGGISTION WORKS GREAT !!!

One more question (if you don't mind): What if the Person's Name has a Middle Initial?

event.value = this.getField("First Name").valueAsString + " " + this.getField("Middle Initial").valueAsString + " " + this.getField("Last Name").valueAsString;

But, if there is "No" Middle Initial, there will be 2 spaces between the First and Last Name

Similarly, I have a "Suffix" field, (ex. John Q Public, Sr.)

I'd like a comma if there IS a suffix, but NO comma if there is no suffix.

Is this possible?

Sorry, I should have included this with my initial question of First and Last Name.

Bernd Alheit
Community Expert
Community Expert
April 10, 2023

Where does you use the script?