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 you have the form below and you 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 you need to design an expression that models our validation.

In this case, you want the calculated question's answer to be "Yes" (when true) when "Number Question 2" is 42 times bigger than "Number Question 1", else "No" (when 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 that's it - you can model almost any validations using the calculated questions!

Useful Examples:

Validate the LENGTH of an answer

To specify the length of an answer, create an extra Calculated Question and give it the following expression:

    LENGTH(field_you_want_to_validate)

This Calculated Question will now display the number of digits in your field’s answer. (You can hide this Calculated Question if you like)

Then place a Validation on your original field, so that the new Calculated Question (Length) must be the same as your desired number or digits.
After saving, the user will be prompted to change their answer, if it isn't the correct length.


If you have any questions or comments please send us a message at support@devicemagic.com or leave us a comment below.

Did this answer your question?