Complex Conditions (AND/OR)

5 min read

When You Need Complex Conditions

Basic show/hide rules work well for simple scenarios, but many forms need more nuanced logic. For example, you might want to show a field only when a respondent selects "Enterprise" as their company size AND their budget is above a certain amount. Or you might want to show a discount field if the respondent is either a student OR a senior citizen.

Complex conditions let you combine multiple rules using AND and OR operators to handle these scenarios.

Combining Conditions with AND

When conditions are joined with AND, all conditions must be true for the rule to trigger. The target field is shown (or hidden) only when every single condition evaluates to true.

Example:

  • IF "Country" equals "United States" AND "State" equals "California" THEN show "California Tax ID" field.

In this case, the tax ID field only appears when both the country is United States and the state is California. If either condition is false, the field stays hidden.

How to Add AND Conditions

  1. Click on the target field and open the Logic tab.
  2. Add your first condition using Add Condition.
  3. Click Add Condition again to add another condition. By default, multiple conditions are joined with AND.
  4. Verify the logic connector between conditions shows AND.

Combining Conditions with OR

When conditions are joined with OR, any one condition being true is enough to trigger the rule. The target field is shown when at least one condition evaluates to true.

Example:

  • IF "Role" equals "CEO" OR "Role" equals "CTO" OR "Role" equals "VP" THEN show "Executive Survey" section.

Switching Between AND and OR

After adding multiple conditions, click the AND label between conditions to toggle it to OR (or vice versa). All conditions within a group share the same connector (either all AND or all OR).

Condition Groups (Nested Conditions)

Sometimes you need a mix of AND and OR in the same rule. Condition groups let you nest logic for more sophisticated rules. Think of groups as parentheses in a math equation: they let you control the order of evaluation.

Example:

  • IF ("Plan" equals "Enterprise" OR "Plan" equals "Business") AND ("Team Size" greater than 50) THEN show "Dedicated Account Manager" option.

Here, the plan must be either Enterprise or Business (first group), AND the team size must be above 50 (second group). Both groups must evaluate to true.

Creating Condition Groups

  1. In the Logic tab, add your first set of conditions normally.
  2. Click Add Group to create a new condition group.
  3. Add conditions within the new group.
  4. Set the connector within each group (AND or OR) and the connector between groups (AND or OR).

Priority and Order of Evaluation

Understanding how WittyForm evaluates complex conditions is important:

  1. Individual conditions are evaluated first: Each condition (field + operator + value) is checked and resolves to true or false.
  2. Groups are evaluated next: Conditions within each group are combined using their group's connector (AND/OR) to produce a single true or false result per group.
  3. Groups are combined last: The results of all groups are combined using the between-group connector to determine the final outcome.

This is analogous to how mathematical expressions with parentheses work: inner expressions are resolved before outer ones.

Real-World Examples

Lead Qualification

Show a "Book a Demo" call-to-action when:

  • ("Company Size" greater than 100 OR "Annual Revenue" greater than 1,000,000) AND ("Interest Level" equals "Very Interested")

Event Registration

Show dietary restriction options when:

  • ("Attending Lunch" equals "Yes" OR "Attending Dinner" equals "Yes") AND ("Has Dietary Restrictions" equals "Yes")

Insurance Quote Form

Show additional coverage options when:

  • ("Vehicle Type" equals "Luxury" OR "Vehicle Year" less than 2020) AND ("Coverage Level" does not equal "Basic")

Testing Complex Rules

Complex logic has more potential for unexpected behavior, so thorough testing is critical:

  • Test the "happy path": Verify that the rule triggers when all conditions are met.
  • Test each condition independently: Change one condition at a time to make sure each contributes correctly.
  • Test the "no match" path: Ensure the field stays hidden when conditions are not met.
  • Test edge cases: Empty fields, boundary values, and unusual combinations.
  • Use the Logic Inspector: In the editor, click the Logic icon in the toolbar to see a visual map of all conditional rules in your form. This helps you spot conflicts or missing rules.

Tips for Complex Logic

  • Start simple, add complexity: Build and test one condition at a time before combining them.
  • Document your logic: Use field descriptions or form notes to record what each complex rule does and why.
  • Avoid over-nesting: If you find yourself creating deeply nested groups, consider whether the form structure could be simplified with page jumps instead.
  • Use descriptive field labels: When you have many conditions referencing different fields, clear labels save significant debugging time.
$37 · paid once

Ready to Build Smarter Forms? Add Logic in Minutes

Start free and keep the five forms for good, or pay once and unlock all of it — unlimited forms, ten team members, AI, CRM, white label and the API. No renewal, ever.

14-day money-backInstant accessNo subscription, ever
Complex Conditions (AND/OR)