Mandatory If Rule Example

   MaestroThe UI design product.  |   Form Builder |  All versions This feature is related to all versions.

As you have learned how to add the Mandatory if rule to any component, let's look at a practical example. Assume you have a credit card application form that asks customers if they would like to apply for a credit card. The rendered form is shown below.

If the answer is yes, then the type of credit card question becomes mandatory as shown below.

To achieve this, you have to write the following JavaScript that checks if the component named kind is equal to "Yes" (that is, if the customer has selected the "Yes" option for the question "Would you like to Apply for a Credit Card?"). If this condition is met then the script returns true and this field becomes mandatory. This is illustrated below.

If a mandatory field is left blank and a user attempts to continue their form journey, the associated error message is displayed.

Next, learn about other Maestro rules.