In this article, we will help you understand how to define a rule on a field in a form using the Form 2.0 Configuration.

Skip Ahead to:

Introduction

Font Color Decorator Rule

Icon Decorator Rule

Validation Rule

Introduction

The rule is useful if you want to set a condition for your field. For example, if a specific value is entered then the color of the field changes to a predefined color to highlight the field. For example, in the Marks column, if a student gets more than or equal to 36 marks, then the field should be highlighted with green color and if a student gets marks below 36 then the field should be highlighted in red color to highlight the value below 36. Similarly, if the user enters a title in the name field, then it should be highlighted in red color to let the user know that titles are not allowed in the Name field.

There are three types of Rules –

  1. Font Color Decorator Rule
  2. Icon Decorator Rule
  3. Validation Rule

Font Color Decorator Rule

The font color decorators help you define rules on a field. If the condition of the defined rule is met, the font of the color is changed as defined in the rule. You can define multiple rules on a field. For example, if you have defined three rules  – Rule A, Rule B, and Rule C and if the condition of the rules A, B, and C are met then the font color should be Green, Blue, and Grey respectively. Now if the condition of rule A is met, then the font color be set as Green. Please note, that at a time only one rule can be executed, and thus the font can take only one color at a time.

To define a rule based on font color, perform the following steps –

  1. Click the Rule tab.
  2. Click the Add Rule button next to Font Color.
    Font Color
  3. Select the name of the field from the Field name list. It displays all the fields available in the form. You can define a rule on the value of any field available in the form.
  4. Select the condition from the Data Condition drop-down list such as if the specified value is equal to or contains the given characters etc. These conditions change as per the field selected in the previous field.

    A number field has the given conditions –

    • is equal to
    • is not equal to
    • greater than
    • greater than or equal to
    • less than
    • less than or equal to

    A text field has the following conditions

    • is equal to
    • is not equal to
    • contains
    • does not contains

    A multi-line and RTF field has the following conditions

    • contains
    • does not contains

    A URL has the following conditions

    • is equal to
    • is not equal to
  5. Enter the value in the Value field.
  6. Specify the color name in the Font color field. If the given condition is met, then the font of the specified field will be set to this color.
  7. To specify more than one condition, click the Add rule icon.
  8. Specify the rule.
  9. Click the Save button.

Please note, at a time only one rule will be executed as the field can have only one color at the time after execution of the rule.

Once you specify all the settings for the field type, click the Save button.

Note – Font Color Decorator rules are available in single-line, multi-line, Numbers, and URL fields.

Icon Decorator Rule

The Icon decorator is used to set icons with the numbers if the given rule is met. For example, if you have defined a rule such as if the mark is less than 50, then a minus (-) icon should be displayed with the number. Similarly, if the mark is greater than 50 then a plus (+) icon should be displayed with the marks.

Similarly, you can define another condition if the number is greater than 50, then it should show the upward arrow icon, if the number is lesser than 50, then it should show the downward icon, if the number is 50 then it should show the straight line icon.

To define a rule based on the icon decorator, perform the following steps –

  1. Click the Rule tab.
  2. Click the Add Rule button next to the Icon Decorator.
    Icon Decorator
  3. Specify the condition such as less than, greater than, or between.
  4. Specify the value and the icon for the conditions.
  5. By default, three conditions are shown, however, you can add or remove them from the conditions.
  6. To add more conditions, click the Add icon.
  7. To remove a condition, click the Delete icon.
  8. To keep the condition same but reverse the order of the icons, turn on the Reverse icon order toggle.
  9. Click the Save button.

Note: Icon Decorator rules are available in the Numbers field only.

Validation Rule

The validation rule is useful when you want to show a message on the screen on certain validations. For example, to make sure that an important field it not left empty, we can configure a validation rule and show the message if the value is not entered by the user in the form. For example, let’s consider that a user must enter some amount in the Price field of a form so we can configure a validation rule that will show the message “Please enter the price of the item to proceed.” if the user leaves the Price field blank and tries to save the form.

To add a rule based on validations, perform the following steps –

  1. Click the Rule tab.
  2. Click the >Add Rule button next to the Validation rule.
    Validation Rule
  3. For the IF condition, select the name of the field from the Field name list. It displays all the fields available in the form. You can define a rule on the value of any field available in the form.
  4. Select the condition from the Data Condition drop-down list such as if the specified value is equal to or contains the given characters etc. These conditions change as per the field selected in the previous field.
  5. Enter the value in the Value field.
  6. For the THEN condition, enter the message that you want to show on the screen if the given condition is met.
  7. Click the Save button.

Note: Validation rules are available in single-line, multi-line, Numbers, and URL fields.

  • Was this helpful?
  • Yes   No