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

    specific number of digits

    Asked by saud2013 on January 12, 2013 at 05:01 AM

    Hello

    I went through the forum looking for an answer to force people to enter a specific number of digits but didn't find what I need. For example,the civil ID consists of 12 numerics not more or less and I want to force them to enter exactly 12 numbers rather than setting the maximum digits to 12 and allowing them to enter less than 12.

    Please give me a straight forward answer. Either it can't be done or it can be with how to do it.

    I tried the min="12" after maxlength="12" but it didn't work.

     

    Regards

  • Profile Image

    Answered by moonzkie on January 12, 2013 at 05:09 AM

    Hi,

    Unfortunately as of the moment there is no option to set the minimum in a field. However, you may find a workaround provided by our colleague Abajan in the following thread.

    http://www.jotform.com/answers/54587-How-do-I-ensure-that-users-enter-no-less-than-a-certain-number-of-characters-into-a-text-box

    Hope you find this useful. Thank you.

  • Profile Image

    Answered by saud2013 on January 13, 2013 at 06:22 AM

    Hello

    I tried the options at that link but it didn't work the way it's supposed to. What happened is that it displays the pop up message but it allows the user to cintinue and submit the form even when the number of digits is less than specified.

    Regards

  • Profile Image
    JotForm Support

    Answered by jonathan on January 13, 2013 at 07:28 AM

    @saud2013

    Hi, the demo provided by Abajan from that thread was only meant to notify/alert the user -- but does not stop proceeding to submit the form.

    This was the code -- you can see it only does a pop-up message.

    function mustBe12() {

    if(document.getElementById("input_5").value.length != 12)

    alert("The NRIC number must be 12 digits long!")

    }

     

    BUT using the same javascript, you can indeed prevent the form being submitted.

    i.e. you can disable the submit button as long as the correct number of digit is not provided.

    Are you able to use the form's source code? This is required to be used on your own hosted website.

    If this is possible on your end, we can assist you achieved the requirements on your form.

    Thanks.

  • Profile Image

    Answered by saud2013 on January 13, 2013 at 07:42 AM

    Yes I can use the form source code and modify it. That's what I did for the pop message from the thread you provided.

    Please give me the code to prevent the submission if that condition is not met.

     

    Regards

  • Profile Image
    JotForm Support

    Answered by jonathan on January 13, 2013 at 07:49 AM

    @saud2013

    Thank you for the immediate update. I'll check for the appropriate javascipt code.

    I'll post it here later. Please wait.

    Thanks.

  • Profile Image
    JotForm Support

    Answered by jonathan on January 13, 2013 at 09:28 AM

    @saud2013

    Hi, please try this code

    function mustBe12() {

    if(document.getElementById("input_3").value.length != 12)

    document.getElementById("input_2").style.display = 'none';

     

    else {

    document.getElementById("input_2").style.display = 'block';

    }

    }

    Just adjust on your code setup.. i.e. input_2 is my submit button.
    I use hide button instead. I found that using the disabled button attribute would require it being disabled by default right on page load, which can be complicated for each different browser javascript settings.
    Hope this help. Inform us if you require further assistance.
    Thanks.