Problem when passing query string to form with a + Sign (%2B)

  • nickbh
    Asked on November 22, 2016 at 4:22 PM

    I have a form that has international phone numbers.  Of course many people enter the international dialling codes

    eg

    +1

    +44

    +33 etc followed by their number.

     

    This is fine and Is what I would like to happen.  However - I use a query string to pre-populate data in a Jot form on occasions.  As a result when I pass the query string with the + sign it gets translated to a SPACE ie " ".

     

    I have tried many different functions in PHP to alter the data so that it is sent using the url code for the + sign.  ie %2B but again it gets literally translated by the input box in the jot form as a space.

     

    Can you check to see how I get around this and what I would need to pass in the query string to ensure the + sign is added.

     

    Note posting the data is fine.

     

    Thanks

     

  • Welvin Support Team Lead
    Replied on November 22, 2016 at 6:57 PM

    Try implementing the URL encode in the URL. Here's an example for the text area: https://www.jotform.com/help/164-Pass-Value-to-Another-Form-with-URL-Encoding. Apply the same for the phone number field.

    If you can't get it to work, I would suggest doing the following which is the simplest method:

    1. Use our phone number field from the Quick Fields section.

    2. Enable the Input Mask

    3. Add + in the Mask value then # for the numbers.

    Problem when passing query string to form with a + Sign (%2B) Image 1 Screenshot 20

     

  • nickbh
    Replied on November 23, 2016 at 5:12 AM

    Hi Welvin,

     

    Ive tried passing the &phone={URLENCODE:+43 (0) 650 22 999}

     

    and it just passes as the text URLENCODE and still removes the plus sign etc>  See>

    Problem when passing query string to form with a + Sign (%2B) Image 1 Screenshot 20

    Ill look into the phone field using the mask.  However it would be nice to understand how the URLENCODE works as i would be useful for me in other forms.

     

    Thanks

     

  • nickbh
    Replied on November 23, 2016 at 5:18 AM

    Hi Welvin,

    Even using the mask the + sign is still trans-coded as a space when posted?

     

    Scratching my head on this one?

    Thanks

    PS My form is still on the old interface?  Not sure if that matters.  Would like it on the new interface but not sure how?

     

  • Boris
    Replied on November 23, 2016 at 6:24 AM

    I'm afraid that as the plus sign (%2B) in URL parameters represents a space character, it is interpreted as such by our URL prepopulation as well.

    Simply put, when passing URL parameters with a plus sign, the plus sign is interpreted as a space. Unfortunately, there is no workaround for going around this behavior of URL parameters.

    As mentioned by my colleague, the only way to ensure that a plus sign is in front of the phone numbers your form is receiving through URL prepopulation is to use an actual Phone field, and enable its Input Mask:

    Problem when passing query string to form with a + Sign (%2B) Image 1 Screenshot 20

    By having a plus sign in the Input Mask, it will ensure that all the numbers have a plus sign in front of them.

    Please let us know should you need further clarifications or assistance.

  • nickbh
    Replied on November 25, 2016 at 10:54 AM

    Thanks for all the info.  I found that the input mask wasn't great as there are many formats and lengths for international numbers.  So as a result I found a workaround by using temp fields and field updates and a bit of PHP processing.

  • David JotForm Support Manager
    Replied on November 25, 2016 at 12:22 PM

    Glad to know you solved it. Open a new thread if you need anything else, we will be glad to assist you.