> ## Documentation Index
> Fetch the complete documentation index at: https://crestform.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional logic

> Show or hide questions based on earlier answers, and in Flow forms skip ahead or end the form early.

Logic lets a form react to answers. Ask follow-up questions only when they apply, skip sections that don't, and end the form early for people who aren't a fit. Each person sees a shorter form that fits them.

## What logic can do

| Action | What happens | Flow | Standard |
| - | - | - | - |
| **Show this field** | The question stays hidden until the conditions match. | Yes | Yes |
| **Hide this field** | The question is hidden when the conditions match. | Yes | Yes |
| **Jump to step** | When the person presses the button on this step and the conditions match, they skip ahead to a later step. | Yes | No |
| **End the form** | When the person presses the button on this step and the conditions match, the form is submitted there and then. | Yes | No |

A Standard form has every question on one page, so there are no steps to jump between. It offers show and hide only.

## Add logic to a question

**1. Select the question**

Click the question (or step) you want the logic to act on. Scroll to **LOGIC** at the bottom of its settings.

**2. Add a condition**

Click **+ Add condition**. Pick an earlier question under **Select a question**, then a comparison (for example **Is selected**), then the value to compare against. For choice questions, pick the value from the question's choices.

**3. Choose the action**

In the first drop-down, pick **Show this field**, **Hide this field**, **Jump to step** or **End the form**. For a jump, pick the step under **Choose a step to jump to**.

**4. Add more conditions if you need them**

Click **+ Add another condition**. Set **if all conditions match** to require every condition, or **any** to need just one.

To remove a condition, click the **×** on it. Removing the last condition removes the logic.

## Comparisons by question type

| Question types | Comparisons |
| - | - |
| Multiple Choice, Dropdown, Checkboxes, Multi-select | Equals, Does not equal, Is selected, Is not selected, Is empty, Is not empty |
| Number, Rating, Opinion Scale, Slider | Equals, Does not equal, Greater than, Less than, Is empty, Is not empty |
| Everything else (text, email, phone, names, date, time, website, hidden fields) | Equals, Does not equal, Contains, Does not contain, Is empty, Is not empty |

A few details:

* Text comparisons ignore capital letters. "Yes", "yes" and "YES" all match.
* For Checkboxes and Multi-select, **Is selected** matches when that choice is one of the ones ticked.
* A range slider is compared by its lower number.

## The rules logic follows

* **Only earlier questions.** A condition can only check a question that comes before the one it's on. The first question has nothing to check, so it has no logic.
* **Jumps go forward only.** You can jump to any later step, never back.
* **One rule per question.** Each question has one action, with as many conditions as you like. If you need two different outcomes, put the second rule on another question.
* **An unanswered question never matches**, except with **Is empty**. "Does not equal Yes" doesn't fire just because someone hasn't answered yet.
* **If a jump's target is hidden**, the person simply moves on to the next step.

## Worked example: end the form for a small budget

A design studio's enquiry form asks about budget on step 3. Small projects get a helpful link instead of a sales call, so there's no point asking them the five detailed questions that follow.

1. **Step 3**, Multiple Choice: "What's your budget?" with Under $2,000, $2,000–$10,000 and Over $10,000.
2. **Step 4**, Long Text: "Tell us about your project".
3. Select step 4. Under **LOGIC**, click **+ Add condition**: **What's your budget?** · **Is selected** · **Under \$2,000**.
4. Set the action to **End the form**.

Now someone who picks Under \$2,000 describes their project, presses the button, and the form is submitted. Everyone else carries on to step 5.

Then go to **After submit** and add a [rule](https://crestform.io/docs/after-submit/rules.md) that sends the small-budget responses to a [redirect](https://crestform.io/docs/after-submit/redirect.md), while everyone else sees your [booking page](https://crestform.io/docs/after-submit/booking-page.md).

> [!TIP]
>
> Click **Preview** to test your logic. Nothing you enter in Preview is saved.

## Related

> [card] [Rules after submit](https://crestform.io/docs/after-submit/rules.md)
>
> Send people to different pages based on their answers.

> [card] [Recall and prefill](https://crestform.io/docs/forms/recall-and-prefill.md)
>
> Use earlier answers in later questions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.