Skip to main content
Henry.Ong
Inspiring
April 17, 2020
Answered

How to concatenate input fields in the PDF form?

  • April 17, 2020
  • 1 reply
  • 5659 views

I know this is a very trival question. I tried the solutions presented here but it doesn't seem to work. Maybe I might have done something wrong.

What I want to combine three input fields in my PDF form into just one field..

FieldName 1 = FIRST NAME

FieldName 2 = MIDDLE NAME

FieldName 3 = LAST NAME

Where:

FIRST NAME = John

MIDDLE NAME = Wilson

LAST NAME = Smith

I wish the result in one field with result "John Wilson Smith". If the individual fields have leading or trailing black, I wish that this character be remove also.

 

Thanks in advance for the help.

 

This topic has been closed for replies.
Correct answer try67

What do you mean by "leading or trailing black"?

 

Basically, you can do it using this code as the custom calculation script of your field:

 

event.value = (this.getField("FIRST NAME").valueAsString + " " + this.getField("MIDDLE NAME").valueAsString + " " + this.getField("LAST NAME").valueAsString).replace(/\s+/g, " ");

 

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 17, 2020

What do you mean by "leading or trailing black"?

 

Basically, you can do it using this code as the custom calculation script of your field:

 

event.value = (this.getField("FIRST NAME").valueAsString + " " + this.getField("MIDDLE NAME").valueAsString + " " + this.getField("LAST NAME").valueAsString).replace(/\s+/g, " ");

 

Henry.Ong
Henry.OngAuthor
Inspiring
April 20, 2020

Leading or trailing blank (not black, my apology) are space before and after the input value.

I have tried the solution you have provided and it works perfectly well. Thank you.

More power to you.