Combine fields, but only add spaces if a field exists

  • grahamlaw
    Asked on October 1, 2022 at 2:49 PM

    I have five different name fields which I would like to combine into a new field called FullName:

    Prefix (e.g. Dr.)
    First Name
    Middle Name
    Last Name
    Suffix (e.g. Jr.)

    While everyone has a first/last name, not everyone has a prefix, suffix, or middle name. So the end result may be "Dr. John Henry Smith Jr.", or it may be "Mr. John Smith"

    Every workaround I try involves creating multiple if/then calculations (one if prefix exists with suffix, one if prefix exists w/o suffix, one if suffix exists w/o prefix, etc) for what should be a simple feature - combining fields, and only adding a space if the field actually exists.

    Is there a simple way to do this with just one calculation, which only conditionally adds spaces if there are fields on both sides of the space?

  • CJ_G
    Replied on October 1, 2022 at 9:16 PM

    Hello grahamlaw,

    Thanks for reaching out to Jotform Support. I assume you are referring to this form. To put all the name fields value together with the right spacing, you may use a Form Calculation widget and then add the fields there. Make sure to change the values of the fields in the Calculation widget from numbers to letters. Here's a demo video on how to do that.

    Give it a try and let us know if you need help.

  • grahamlaw
    Replied on October 1, 2022 at 10:44 PM

    That's not doing it. I know how to combine fields, and have already done that. But in your own demo, when a field is empty, there is an extra space (e.g. if there's no prefix, then there's a space before First Name) - since I use the name field for drive names and in contacts, I cannot have extra leading or trailing space.

  • Billy JotForm Support
    Replied on October 2, 2022 at 12:33 AM

    Hello,

    The Full Name widget itself has these options built-in. Please see the screenshot below:

    1664685113 63391439c8370  Screenshot 10

    Result:

    1664685179 6339147b350bd  Screenshot 21

    Let us know if there’s anything else we can help you with.

  • grahamlaw
    Replied on October 2, 2022 at 11:52 AM

    I like the name field, and have been experimenting with it, but is there a way to have the full name, including prefix/suffix filled in (so I can pass that information to Google Contacts), but then have the Full Name field use only the name fields, and not the prefix/suffix?

    Thus far, I think I can use Zapier to do that before the folders are created, but I was really hoping to do as much as possible in Jotform at the time the data is inputted.

    Thanks, Carl.

  • Camila JotForm Support
    Replied on October 2, 2022 at 1:52 PM

    Hello Carl,

    Thanks for reaching out to Jotform Support. Thank you for your feedback. I’ll need a bit of time to look into this. I’ll get back to you as soon as I can.

    We really appreciate your patience and understanding while we handle your request.