Sometimes the validation builder is not advanced enough for some of the rules you would like to build, such as checking the field against another field, or some other calculations.
When this happens the best thing to do is to make a calculated question with the validation you want - and then use that question in the Validation builder.
In this article we will walk through building an advanced validation in the designer.
The same technique can be used to Active and Read-only rules.
Assume we have the form below and we want "Number Question 2" to be valid only when it is at least 42 times larger than "Number Question 1".
Step 1 - Add calculation question for validation
Add a calculation Question to the form, the name is not important but it can help to be descriptive, so lets call it "Number Question 2 is Valid"
Step 2 - Set Expression to be our validation
Now we need to design an expression that models our validation.
In our case we want the calculated question to be "Yes" (or true) when "Number Question 2" is 42 times bigger than "Number Question 1", else "No" (false).
So the expression should look like
Number_Question_2 > (42 * Number_Question_1)
You could also use an IF statement to be more specific.
IF(Number_Question_2 > (42 * Number_Question_1), true, false)
Step 3 - Use our calculated question in the Validation builder.
Now we just base the validation rule for "Number Question 2" off whether our calculation question is "Yes"(true) or "No"(false).
Step 4 (Optional) - Hide the calculated Question
Sometimes it can be nice for the user to see immediately whether the answer is valid as the calculation will resolve to "Yes" or "No", but in some cases you will want to hide the calculated validation question.
In these cases just tick the "Hide from user" check box in the calculated question's advanced settings.
If you want to know more about hiding calculated questions you can read the article here.
And thats it - you can model almost any validations using the calculated questions! If you have any questions or comments please send us a message at email@example.com or leave us a comment below.