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

    Is there a way to validate a text field where it has to be a certain number of digits?

    Asked by dano2334 on August 15, 2014 at 08:23 AM
    text field validate
  • Profile Image

    Answered by jedcadorna on August 15, 2014 at 10:49 AM

    That is possible by setting a validation to your text field. You can set it as 'numbers' then apply input mask so you can format the numbers that will be inputted into your text fields.

    You can set your input mask like this:

  • Profile Image

    Answered by dano2334 on August 15, 2014 at 11:48 AM

    But I don't want the user to know how many digits needs to be entered.

  • Profile Image
    JotForm Support

    Answered by david on August 15, 2014 at 12:48 PM

    Hi,

    Unfortunately this is not possible without using your forms source code and embedding it to a web page.  Here is a discussion on how to accomplish this if you are willing to do so:

    http://www.jotform.com/answers/158697-I-need-a-way-to-validate-that-a-10-digit-numeric-account-number-has-been-entered

    Essentially you would need a script such as this one in your page to run the validation:

    <script type="text/javascript">
       
      (function () {
      var accountNum = document.getElementById("input_5"),
      valid = /^[0-9]{10}$/;
       
      accountNum.onblur = function () {
      if (valid.test(accountNum.value) === false) {
      alert("Please enter a ten (10) digit number!");
      accountNum.value = "";
      }
      };
      })();
       
      </script>

    Then you would substitute "Input_5" with the field ID in your form you wish to validate.

    Please let us know if you have any further questions and we will be happy to help.

    Thank you for using JotForm!