Optimization tips > Using a value rule

Using a value rule to restrict the data you collect

Make sure the user fills in the data according to your guidelines

Amy W, 6/12/2016
Make sure the user fills in the data according to your guidelines


What is a value rule?

Validation rules are used to restrict data input by specifying a criterion that all valid field values must meet. These validations work while the visitor is filling in the form, before it is submitted.
There are common field validations we all know, such as an “email validation”. In this validation the email field is checked and an error message is given if the format of the email address is not correct. In addition, there are custom field validations a form owner can decide to apply specifically on his form in order to collect a certain kind of data.

Examples of value rules

If for example (and a very far fetched one at that) the owner of the form wants only people whose name is “john” to fill in the form, he can do so by defining a value rule on the name field, stating that it must contain the word “john”.
Stumbling over this kind of example, however ridiculous it sounds, can happen. just like it did to the author of the post: “A Definitive Guide to Sensible Form Validations”. “Here is one of form validation error messages that made me laugh aloud : “invalid last name. Please enter a valid last name”. The form (or the souls that coded that form) decided my last name is bad and imagine, they want me to build a valid last name too!”

More reasonable and realistic examples of using the value rule could be:
1- restricting the number of characters of a code or password field
2- defining a range of numbers in a numeric field.

Advise on how to improve the value rules

Just keep in mind that while using a value rule you can make sure the user fills in the data according to your guidelines, however, you must also be careful not to scare the user away. Do it in a friendly and helpful way, for example: Report the errors early. Don't let the user wait until he presses the “submit” button.

Let him know it is incorrect the same moment he types it in, or right after - this is called “inline validation”.
Alex Birkett, in his post “How to Get Form Validation Right” says that “In general, there are two main types of form validation:
1. After Submit Validation
2. Inline Validation.” He also explains what inline validations messages “are shown immediately after the user types in data to form fields.”

"Apart from the error message and a list of invalid fields" says Janko Jovanovic "the system should clearly mark fields that are invalid. This can be done in one of the following ways (or any combination of them):
By providing red inline messages or markers next to every invalid field
By changing the background color or border color of invalid fields (to red)
By changing the color of field labels
By providing error tips (balloons) next to each field". 
(“Web Form Validation: Best Practices and Tutorials”).

Additional advice is to display hints, or examples of the kind of data you want the user to enter. You can add a label next to the field or use a placeholder inside the element to take care of this.

Another good thing you can do to better your form in terms of value rules is to use both a positive and a negative feedback in your form, so when someone enters a correct value a positive sign appears (“ok” label, a v mark etc). This feature may also be found in FormTitan form builder.

Luke Wroblewski also wrote a post about online validation called “Inline Validation in Web Forms”. In this post he says that “Inline validation gives people several types of real-time feedback: It can confirm an appropriate answer, suggest valid answers, and provide regular updates to help people stay within necessary limits. These bits of feedback can be presented before, during and / or after users provide answers.”


Using value rules in FormTitan

formTitan allows its users to create smart forms. One of the ways to do that is with value rules.
Once a user tries to enter a different value than the options you defined for your form a red inline message will appear to correct them.

Following are steps to add value rule to your FormTitan form:
1- enter your form in the form builder
2- select the field you would like to add a value rule to
Value rule property

3- go to Element settings > Advanced tab > Value rule
4- Configure the rule. For example: “contains” “John” means that the selected field must
Be entered with a value that consists of this value.
Configure value rule

5- Press on “apply” and your rule is set.
6- and finally, in the published form -if a user tries to enter a value that does not include “john” he will get this message instantly. 

 Value rule in action