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.
How can we impose validation on form fields?Asked by drvbanthia on November 19, 2014 at 01:44 PM
how can we impose validations on forms?
for example -- zip code needs to have 5 numbers
name has to have have letters and no number
phone number: area code has to have 3 numbers, etc..
name phone number zip code validation restrict characters number of characters number of letters number of digits field validation input mask masking
Thanks for asking. Depending on the type of field, there are various ways to do this. For example, in this demo I just made, although there's no way (that I know of) in the form builder to apply validation to the default Full Name field, if a separate text box is used for each part of the name, entries can be restricted to letters by clicking the Validation button and selecting Alphabetic:
Incidentally, there's also an Input Mask feature available for text boxes:
That brings us to the Zip Code field. To restrict zip codes to five (5) digits, you would enter ##### for the mask. However, the input mask feature is capable of more than that. Let's say you wanted to format the zip code as letter, digit, letter, space, digit, letter, digit (as is the case in Canada), you would enter @#@ #@#.
Phone Number fields also have the input mask feature but it's a bit different in that there are two separate buttons, as shown below:
Phone number validation is set by clicking the Mask Value button, and by default, the mask is (###) ###-####. However, as you would have discovered, the masking is not in effect by default. You would need to click the Input Mask button, so that it shows On (as shown in the screenshot). But there's more! Notice how there's a Fill Mask Validation checkbox in the Mask Value section. This ensures that users enter complete phone numbers. With that box checked, if complete numbers are not entered, users will see Field value must fill mask. as soon as they move to another field:
The error message can be edited to suit.
If this were to be used in combination with Required field validation,
as in my demo, the user would get a This field is required. message if they don't enter any phone number and Field value must fill mask (or whatever message you prefer) if they enter an incomplete one.
That's pretty much it. If you need clarification on anything, please let us know.