5. Rule Builder

You are here:
< All Topics

Rule Builder

  1. Introduction
  2. Requirements
  3. No limitations
  4. Add your first rule
  5. Rule Structure
  6. Conditional Validation

Introduction

The Rule Builder enables you to add logic into your surveys and forms. You simply add a number of conditions to add actions such as hide/show fields, enable/disable fields, copy fields, skip to pages and do maths.

To access the Rule Builder you must go to Form Manager, click the Actions button to the corresponding form, then Conditional Rules.

Rule Builder - Conditional Logic

Requirements

Before using the Rule Builder, your form must have at least one field in your form/survey.

Rule Builder - Requirements

No limitations

There are no limitations to the number of rules.

To add your first rule

First, create your form/survey with four fields:

  • Name (text field)
  • Email (email field)
  • Message (text area)
  • Button (with text Submit)
Rule Builder - Contact Form

Then, go to Form Manager, locate your form, click on the Actions button, and then click Conditional Rules.

  1. In the blank panel, click the Add Rule button.
  2. You will then see two lines, the first line is for the conditions and second for actions.
  3. Click the Add condition button, then the first field of the form will appear. In our example, the first field of the Form is a Text field with the ‘Name’ label. The Rule Builder will show the condition ‘Name’ ‘is present’.
  4. Click the Add Action button. The list shows the action to perform (For this example, leave in ‘Show’); the second line shows the type of result (For this example, leave ‘Field’) and the third, the field label: ‘Name’. In this example, will change it to ‘Submit’ (The text ‘Submit’ refers to the button).
  5. In the top right of this rule, you will notice the small orange warning “Unsaved Changes” next to a green button with the Check icon. Click on this button to save this rule. The warning will disappear.

You will have now created your first rule.

A1Surveys - Form Rules

If you now test your form, you will notice that the button has disappeared, but if you enter a text in the ‘Name’ field, the button appears.

A1Surveys - Contact Form Demo

You should be aware that some rules are met bidirectionally. If the condition has been fulfilled the action will be executed, but if the condition has not been fulfilled the opposite action will be executed (Show <=> Hide, Enable <=> Disable).

You can add additional rules by clicking the “Add Rule” button, but this will not be saved until you press the green button. Remember that each rule will be stored separately.

Note: To delete a rule, click the red button with the Trash icon. If you wish to stop executing a rule, you can disable it and then enable it when you need it.

Rule Structure

A conditional rule is composed of three parts: Name/Description, Conditions and Actions.

A1Surveys - Rule Builder

Name / Description

The first part allow us to describe the rule.

Conditions

Specify the field or fields that need to be evaluated, as the type of evaluation.

  • Type of Condition: The condition type indicates how many conditions must be met to execute the action.
  • Condition: Is the statement refer to a form field and must be fulfilled. It consists of 3 parts.
    • Name The name of the form field on which the condition is based.
    • Operator: The comparison operator used to evaluate the condition.
    • Value: It is an arbitrary value that the user must enter into the Form. The way Values will be defined is going to vary according to the type of field and the type of operator.
  • Multiple conditions: You can add multiple conditions to a rule. The type of condition will indicate if all must be met (AND), if any (OR) or none.
  • Group of conditions: In addition to conditions, a rule can contain a group of conditions. A group of conditions differs from a condition that allows for changing the type of condition. So a rule can be of type All (AND), but the group can be of type Any (OR).
  • Evaluation Process: The conditions evaluation process is top-down. That is, the conditions at the beginning will be evaluated before those who are at the end, in descending order.

Note: Conditions “Belongs To” and “Does not Belongs To” can analyze multiple values separated by “|”, this allows you to compare the field value with multiple values, if one of them matches the action will be executed.

Actions

The last part of a rule indicates the action to be performed if the conditions are met. As conditions, actions have a declarative easy way to understand.

An action consists basically of three parts:

  • Action Type:
    • Show / Hide
    • Enable / Disable
    • Copy: Let you copy the value of a field or another element and paste it to another field automatically. A great example of where this is useful is on a Form where you might be collecting a Shipping and Billing address. The end-user could enter their Shipping address and check the Copy option to automatically fill the Billing Address Fields with the same data.
    • Math: Allows Addition / Subtraction / Multiplication / Division / Remainder of fields and show the result in another field or HTML element.
    • Evaluate: Allows the evaluation of expressions (formulas) and set the result in another field. It is also compatible with date calculations. For example, if you want to calculate the multiplication of two fields and divide this value by 10, you use the following formula: {{number_1}} * {{number_2}} / 100. Please note that the evaluation of expressions doesn’t work with opposite actions.
    • Number Format: Allows you to format a number in different ways and without any coding. For example, to give the currency format to a number: 10110.15 use the following format ‘$0,0.00’, and the number will now be displayed as $10,110.15.
    • Text Format: Allows you to select multiple fields to create a new formatted text string and set the result in another field or HTML element. Eg. To auto-generate an email address, select a Name field and enter the following format {{0}}@example.com, then select the Email field where the email address will be displayed. You can use number tokens to identify the field position in the field list, or you can use the Field ID or Field Alias, in our example: {0}@example.com or {{text_1234}}@example.com or {{name}}@example.com should work.
    • Skip: To a page. This action should only be used in a Multi-Step Form.
  • Target: Will vary depending on the type of Action. It can be of two types:
    • Field
    • Element
  • Name:
    • If Target is Field, then it will be the field name.
    • If the Target is Element it will be among several HTML elements selected by jQuery. For instance:
      • ‘#abc’: The target is the HTML element with ‘abc’ as ID.
      • ‘.abc’: The target is all HTML elements with ‘abc’ as the CSS class.
  • Opposite Actions: If after meeting a condition I want to show a field, then by not meeting the condition I want to hide the field. There are occasions when the disabling of opposite actions can be helpful.
A1Surveys - Rule Anatomy

Note: You can identify the ID and CSS Class of the form fields using the Code tab of the Form Builder.

Conditional Validation

You can omit a required field validation by using conditional rules in two ways:

  1. When the field is hidden.
  2. When the field belongs to a page that has been skipped.

If a field is created with rules defined that the field should only be displayed if another field meets a condition and the condition is not met, then the field will no longer be required.

Note: To use Conditional Validation, the client-side validation must be disabled. (See Form Settings -> No validate))

Previous 4. Theme Designer
Next 6. Submission Manager
Table of Contents