Overview
Using the Field Rules, you can choose to
show or hide certain form fields to your respondents or
set certain fields as mandatory to fill in based on their previous responses on the form. This way, you can let your respondents see only the fields that are relevant to them by minimizing the questions that are irrelevant to them, or get input for the mandatory fields, and personalize and streamline the form filling experience for each respondent.
For example, if a user answers "Yes" to a question about whether they are a vegetarian, the form may display a series of questions about their dietary preferences and if the user chooses "No," the form may skip those irrelevant questions and move on to the next.
Field Rules in Zoho Forms can be configured for both basic and
advanced scenarios.
Before we understand how Field Rules work, let us first understand what AND, OR connectors mean in Rules.
AND: If you require all the conditions in a rule to be satisfied at the same time to perform the intended action, use the AND operator.
OR: If you require at least one of the conditions in a rule to be satisfied to perform the action, use the OR operator.
Field Rules can be used in scenarios where actions are taken when all or any of the defined conditions are met.
Assume you have three requirements (Condition 1, Condition 2, and Condition 3) to execute Action 1 and Action 2.
You can setup Field Rules to perform the actions when:
- All the 3 conditions are satisfied:
If Condition 1 AND Condition 2 AND Condition 3 are true -> then perform Action 1 and Action 2.
- Any of the 3 conditions are satisfied:
If Condition 1 OR Condition 2 OR Condition 3 are true -> then perform Action 1 and Action 2.
How to show/hide fields with conditional rules
To show or hide certain fields based on a defined set of conditions, you can use Field Rules.
For example, assume you have a Room Reservation Form where you want to display the
Additional Charges Applied only when your customers require additional services like, a room with a riverview, extra bedding, or a chauffeur for pick up.
To configure Field Rules to Show/Hide fields,
- After building your form, navigate to the Rules tab.
- Under Field Rules, click Configure Now.
- Define your conditions in the If section by choosing your form fields and the criterion they must satisfy. To add more than one condition, click theicon.
- A rule can be executed if at least one of the defined conditions is satisfied or if all of the conditions are satisfied. To define this, choose AND/OR connectors between your conditions. Click the connector to switch between AND / OR.
In the
Then section, choose the action
Show or
Hide fields and select the required fields in the
Search Fields box to show up or hide fields in your form when the defined set of conditions are satisfied. Click the
icon to define more than one action.
If your use-case requires the use of AND and OR operators within the conditions of the same rule, you can
Switch to Advanced Rules. Note that once you switch, all the Field Rules you will configure for your form moving forward will be in the Advanced Rule format.
- Once you have configured the rule(s), click Add to save and view the rule summary.
- To add more rules, click in the top right corner.
- To filter rules, click the filter icon in the top-right corner.
Using Grouped Choices with conditional rules
You can configure field rules to work with
grouped choices of a dropdown field.
To do so,
- Go to Rules > Field Rules and click Configure Now.
- Define your conditions in the If section by choosing your form fields and the criterion they must satisfy. To add more than one condition, click theicon.
- A rule can be executed if at least one of the defined conditions is satisfied or if all of the conditions are satisfied. To define this, choose AND/OR connectors between your conditions. Click the connector to switch between AND / OR.
Under Then section, you can choose between Show Grouped Choices or Hide Grouped Choices.
- Click Add to view the rule summary.
- To add more rules, click in the top right corner.
- To filter rules, click the filter icon in the top-right corner.
Although you can choose certain fields to be mandatory in the Properties pane of the respective fields on your form builder, you can make certain fields as mandatory if the set conditions are satisfied.
For example, assume you have an Event Registration form, and if your respondent chooses to bring guests, you can make the number of guests field mandatory in order to get a head count.
To configure Field Rules to set fields as mandatory,
- After building your form, navigate to the Rules tab.
- Under Field Rules, click Configure Now.
- Define your conditions in the If section by choosing your form fields and the criterion they must satisfy. To add more than one condition, click theicon.
- A rule can be executed if at least one of the defined conditions is satisfied or if all of the conditions are satisfied. To define this, choose AND/OR connectors between your conditions. Click the connector to switch between AND / OR.
In the
Then section, choose the action
Set Fields as Mandatory and select the required fields when the defined set of conditions are satisfied. Click the
icon to define more than one action.
- Once you have configured the rule(s), click Add to save and view the rule summary.
- To add more rules, click in the top right corner.
- To filter rules, click the filter icon in the top-right corner.
Note:
- The fields involved with the Set Fields as Mandatory action cannot be marked as mandatory in the field properties of the form builder.
- Fields that have been marked as mandatory in the form builder properties will not available to use with the Set Fields as Mandatory action in the Field Rules.
- The Set Fields As Mandatory action is supported only if you have switched to Advanced Rules.
Restrictions while configuring Field Rules
A Condition field should come prior to the Action field in the form builder for the rule to work.
For example, if you have configured a Field Rule to show the Email field only when the user chooses the mode of communication to be Email :
In the above rule,
Condition field -> Mode of communication
Action field -> Email
For this rule to work, the Condition field ( Mode of communication ) should come prior to the Action field ( Email ) in your form.
If you try to change the position of these fields in the form such that Email field comes prior to the Mode of Communication field, you will encounter an error.
- Except for the Set Fields as Mandatory action of the Field Rules, subform fields cannot be used to configure the conditions or actions.
Supported Operators
Text and field comparison
- Is: Checks if the selected field is equal to the set value
- Is Not: Checks if the selected field is not equal to the set value
- Is Empty: Checks if the selected field is empty
- Is Not Empty: Checks if the selected field is not empty
- Contains: Checks if the selected field contains a value in the condition
- Not Contains: Checks if the selected field does not contain a value in the condition
- Contains Any Of: Checks if a field contains any of the selected choices
- Contains All Of: Checks if a field contains all of the selected choices
- Contains None Of: Checks if a field contains none of the selected choices
- Starts With: Checks if the selected field starts with the given value
- Ends With: Checks if the selected field ends with the given value
Choice and selection
- Other Choice Is Not Empty: Checks if a value is entered in the Other choice
- Is Any Of: Checks if any of the choices chosen in the condition match
Is None Of: Checks if none of the choices chosen in the condition match
Less Than: Checks if a number is less than a given value
Greater Than: Checks if a number is greater than a given value
Less Than or Equal To: Checks if a number is less than or equal to a given value
Greater Than or Equal To: Checks if a number is greater than or equal to a given value
Between: Checks if a number/date is between 2 given values
Not Between: Checks if a number/date is not between 2 given values
Date and Time Comparison
Day of the week
Day Is: Checks if a date falls on the selected day of the week
Day Is Not: Checks if a date does not fall on the selected day of the week
Is Any of Selected Days: Checks if a date falls on any of the selected days of the week
Is None of Selected Days: Checks if a date does not fall on any of the selected days of the week
Is Previous Day: Checks if a date falls on the previous day
Is Current Day: Checks if a date falls on the current day
Is Next Day: Checks if a date falls on the next day
Is Before [x] Day(s): Checks if a date falls 'x' number of days before the current date
Is After [x] Day(s): Checks if a date falls 'x' number of days after the current date
Is Previous Week: Checks if a date falls in the previous week
Is Current Week: Checks if a date falls in the current week
Is Next Week: Checks if a date falls in the coming week
Is Previous Month: Checks if a date falls in the last month
Is Current Month: Checks if a date falls in the current month
Is Next Month: Checks if a date falls in the next month
Month Is: Checks if a date falls in selected month of the year
Is Any of Selected Months: Checks if date falls in any of the selected months of the year
Is None of Selected Months: Checks if date does not fall in any of the selected months of the year
Is Previous Year: Checks if a date falls in the last year
Is Current Year: Checks if a date falls in the current year
Is Next Year: Checks if a date falls in the coming year
Year Is: Checks if a date falls in selected year
Is in the Past: Checks if a date falls in the past
Is in the Future: Checks if a date falls in future
Time
Time Is Before: Checks if the time falls before the specified time.
Time Is After: Checks if the time occurs after the specified time.
Time Is Between: Checks if the time falls between two specified times.
Time Is Not Between: Checks if the time is outside the specified time range.
Time Is: Checks if the time matches the specified time.
Time Is Not: Checks if the time does not match the specified time.
Time on previous day
Is Previous Day Before: Checks if the time on the previous day is earlier than a specified time.
Is Previous Day After: Checks if the time on the previous day is later than a specified time.
Is Previous Day Between: Checks if the time on the previous day is within a specified time range.
Is Previous Day Not Between: Checks if the time on the previous day is not within a specified time range.
Is Previous Day At: Checks if the time on the previous day matches a specified time.
Is Previous Day Not At: Checks if the time on the previous day does not match a specified time.
Is Current Day Before: Checks if the time on the current day is earlier than a specified time range.
Is Current Day After: Checks if the time on the current day is later than a specified time range.
Is Current Day Between: Checks if the time on the current day is between a specified time range.
Is Current Day Not Between: Checks if the time on the current day is outside a specified time range.
Is Current Day At: Checks if the time on the current day matches a specified time.
Is Current Day Not At: Checks if the time on the current day does not match a specified time.
Is Next Day Before: Checks if the time on the next day is earlier than a specified time.
Is Next Day After: Checks if the time on the next day is later than a specified time.
Is Next Day Between: Checks if the time on the next day is within a specified time range.
Is Next Day Not Between: Checks if the time on the next day is outside a specified time range.
Is Next Day At: Checks if the time on the next day matches a specified time.
Is Next Day Not At: Checks if the time on the next day does not match a specified time.
True: Checks if logical TRUE value is returned
False: Checks if logical FALSE value is returned
The following table lists the operators that can be used with the corresponding field types to form a rule criteria in the If section: