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.
Is there a way to make a field a set number of characters/digits?Asked by surfcity on May 30, 2013 at 07:51 PM
I have a field on my form for clients to enter their AAA number. The number is always 16 digits in length. I have instructions that advise them to be sure to give all 16 digits, but sometimes they don't, then their information is useless. I'd like to have a way to make the field be rejected if they enter a card number of the wrong length. So if they enter 6 digits or 15 or 7 or whatever, the form would reject the submission and point them back to correct the field.
BTW, the field cannot be made mandatory, because not all clients have AAA cards. However, for clients who DO have the card, I need to be sure that the correct number of digits is entered on a mandatory basis, otherwise, they are just wasting their time. A wrong card number will not serve any purpose.
number of characters length mandatory
Actually, if a condition is attached to the field to only show it when the preceding field ("Member of AAA ...") is not equal to "No", it can be made mandatory. (If a field is set to "Required" but is hidden, the form can be submitted without that field being filled.)
The "AAA # ..." field can be set in the form builder to only accept digits by clicking it, clicking the Validation button and selecting Numeric:
However, since the Conditions tool currently has no "check length of entry" functionality, the only way to ensure that users enter exactly 16 digits would be to get a copy of the form's full source, embed it into a web page and add a short script to the said page.
I'll clone the form and work on a solution and get back to you.
If the functionality demonstrated at this link is okay, please load your form in the form builder (editor) and do the following:
1. Click the AAA # (please include all 16 digits): field and
a. Set it to "Required"
b. Click the Validation button and select Numeric, as explained above
c. Click the Max Size button and enter 16
2. Click the Setup & Embed tab > Conditions > Next
3. Create the following condition and save it:
4. Save the form
6. Copy this code and paste it into the same page, anywhere after the form's code (preferably, just before the page's closing body tag, as in the source of my demo)
That should do it but if you would like clarification on anything or experience any difficulties, please let us know.
I have a similar requirement, but I am validating the length of a cell phone serial number. It can only be 3 different lengths: 8, 11, or 14 characters. How do I modify the suggested code to fit my situation?
Hello wireleddunltd,Kindly open a new thread so we can better track the issues and solutions users are having.To assist you better and avoid confusion.Thank you and looking forward to assist you.
Thank you. I just submitted it to the forum as a new question.
I have replied on your thread here
Kindly do this everytime you have any inquiry.
Thank you so much.