There are few occasions where you may want to add complex form conditions to your form fields, and it may lack readability to input so many form validation in a single validation box.
β
In a short guide, I'll show you how to compute four conditional operators neatly.
Let's say you want to submit a form where a user's first name is Aron or Paul and when the user's last name is Stone or Annabel.
We'll add two form fields, Firstname(fname) and Lastname(lname).
β
Click on Conditional Validation (We'll use expressions to validate the form input. To learn more about expressions, kindly take a look at this article).
In the Expression field, input the form validation expression. You can use the online Conditional Generator to generate the condition. e.g.
fname == "Aron" or fname == "Paul"
In Error Message, you can type the error message you want to display to your users when the condition is not satisfied.
Field ID to attach the error to is optional, but you can assign the position on your form field where you want to show this error.
Now, we'll click on the duplicate icon to merge another condition.
You can choose to hide the submit button if the user's input doesn't match the condition by setting the "Also hide the Submit button if the condition is not satisfied" to Yes.
Finally, we'll configure the last name field condition.
β
Input the conditional validation in the Expression field. e.g.
lname == "Stone" or lname == "Annabel".
In Error Message, type or customize the error message you want to display to your users.
Field ID to attach the error to is optional, but you can assign the position on your form field where you want to show this error.
Activating Also hide the Submit button if the condition is not satisfied to Yes, on the second condition will hide the button except when both form fields conditions are met.
That's it, we're done.ππ