What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.

  • Profile Image

    I am using the last 4 digits of the provided phone field as the Unique

    Asked by Antonio on June 27, 2012 at 12:01 AM

    I am using the last 4 digits of the provided phone field as the Unique ID. So far, the user needs to imput the last 4 digits in a separate field. Would it be possible to have an hidden field with a code to collect the last 4 digits of the provided phone number? Thanks in advance.

    This is a re-post of a comment on How to Add Custom Unique IDs to your Form Submissions?

  • Profile Image
    JotForm Support

    Answered by abajan on June 27, 2012 at 12:09 AM

    Yes, that can be done but you would need to get a copy of the form's full source from the Embed Form Wizard and then add a script to populate the hidden field with the number entered in the last input of the phone field. Incidentally, it's not necessary to have that section as a separate field for this to work.

    I should have a solution for you by sometime tonight or tomorow.

  • Profile Image
    JotForm Support

    Answered by abajan on June 28, 2012 at 01:17 AM

    Okay, here's a demo form which has the functionality you want. Regardless of the length of the phone number, its last four digits will populate the hidden field. If the form is completed and submitted, you'll see the ID in the thank you message. (Of course, you won't necessarily want to reveal the ID to the user. This is just to show that the demo works.)

    To implement this solution in your own form, do the steps below. (Referring to the source of the demo while following the instructions should make it easier to understand what to do.)

    1. Load the form into the form builder and insert a phone field and a hidden field

    2. Go to the Setup and Embed tab and click Embed Form

    3. Click Source and when the next panel slides into view, copy the code provided

    4. Paste that code into the web page where you want the form to appear

    5. Search the form's code for the input tag of the last section of the phone number (it will have an ID similar to input_4_phone) and insert an attribute of onkeyup="populateId();" anywhere in the tag

    6. Just before the page's closing body tag, insert this code

    7. On line 4 of the code inserted in step 6, change the ID (highlighted in red) to that of the second input of the your form's phone field:

    var phone = document.getElementById("input_4_phone").value,

    8. On line 8 of the same code, change the ID (highlighted in red) to that of the hidden field:

    document.getElementById("input_6").value = converted.substr(-4, 4);

    (Regardless of where the hidden field was inserted while editing the form in the form builder, in the code it will always appear just before the closing form tag. However, in the form's submission records it will be positioned where you placed it.)

    That should do it. If you need clarification on anything, please let us know.

  • Profile Image

    Answered by puro on June 28, 2012 at 09:52 AM

    Works like a charm! Thanks for the Magic!!! Regards, Antonio

  • Profile Image

    Answered by gori-mathew on June 28, 2012 at 04:25 PM

    On behalf of our able support team member abajan, welcome and glad to know this worked well.

  • Profile Image

    Answered by ikhwanasli on October 20, 2015 at 10:57 AM

    what if i use text box for input phone number.  how can i collect the last 3 digits of the provided phone number? 



  • Profile Image

    Answered by Boris on October 20, 2015 at 12:26 PM

    ikhwanasli, in order for us to better assist you with your query, your question has been moved to its own thread:


    We will be supporting you there, shortly. Thank you.