# Conditional logic

Show, hide, require, and branch based on answers.

## Conditional logic

Logic blocks react to what a respondent enters — show or hide any block, jump to pages, block submission, or calculate values. Layer simple rules into sophisticated branching without code.

<h2 id="what-logic-can-do">What logic can do</h2>

<p>
  Every logic block has one or more <strong>rules</strong>. Each rule pairs a <em>condition group</em> (when should this fire?) with one or
  more <em>actions</em> (what should happen?). Nine action types are available:
</p>

<h2 id="adding-a-logic-block">Adding a logic block</h2>

<p>
  A logic block is a document element — it sits on the canvas between questions, just like a heading or an image. You can place it anywhere:
  between two fields on the same page, at the top of a page, or right before a page break.
</p>

<h2 id="conditions">Conditions</h2>

<p>
  Conditions are the <strong>When</strong> side of a rule. Each condition picks a <strong>field</strong>, applies an{' '}
  <strong>operator</strong>, and often compares against a <strong>value</strong>. The field picker groups what you can watch:{' '}
  <strong>Questions</strong>, <strong>Hidden Fields</strong>, <strong>Calculated Fields</strong>, and <strong>Metadata</strong> (today, the
  respondent's locale).
</p>

<h3 id="all-or-any">All or Any</h3>

<p>Once a rule has two or more conditions, a toggle appears at the top of the When section:</p>

<ul>
  <li>
    <strong>All</strong> — every condition must be true for the rule to fire. The rows read "and".
  </li>
  <li>
    <strong>Any</strong> — one true condition is enough. The rows read "or".
  </li>
</ul>

<h3 id="sets-of-conditions">Sets of conditions</h3>

<p>
  <strong>Add a set of conditions</strong> nests a second group inside the first, one level deep, with its own All/Any toggle. That covers
  compound logic like "plan <strong>is</strong> Pro <em>and</em> (country <strong>is</strong> Norway <em>or</em> country <strong>is</strong>{' '}
  Sweden)". A set holds conditions only — it cannot hold another set.
</p>

> ⚠️ **A hidden question has no value**
> <p>
>     If logic hides a question, the answer it may already hold counts for nothing — not in conditions, not in calculations, not in the
>     payment amount, and not in the stored submission. The answer comes back only if the question becomes visible again. The same goes for
>     every question inside a hidden row, column or repeating group, and for a picked option that logic hides. A page that the Set next page
>     rules skip counts as hidden too: its questions are not required, and whatever was answered there is dropped. Hidden <em>fields</em> are
>     the opposite: they always carry their value.
>   </p>

> 💡 **Keep it readable**
> <p>
>     If a single logic block feels too complex, consider splitting the logic across multiple logic blocks or restructuring your form pages.
>   </p>

<h2 id="operators-reference">Operators reference</h2>

<p>
  The operator list is decided by the field you picked — you only ever see the ones that field supports. Below, each heading names the exact
  set.
</p>

<h3 id="text-text-input-text-area-and-text-calculated-fields">Text (Text Input, Text Area, and text calculated fields)</h3>

<p>
  Every text comparison ignores letter case and spaces at either end, so <code>x@Competitor.com</code> ends with{' '}
  <code>@competitor.com</code>.
</p>

<p>The other text-like inputs carry a narrower set, so pick the type that matches how you need to compare:</p>

<h3 id="numeric-number-star-rating-linear-scale-numeric-hidden-and-calculated-fields">
  Numeric (Number, Star Rating, linear scale, numeric hidden and calculated fields)
</h3>

<h3 id="checkboxes-and-picture-choice">Checkboxes and picture choice</h3>

<h3 id="dropdown-and-radio-buttons-single-select">Dropdown and Radio Buttons (single-select)</h3>

<h3 id="toggle-switch-and-boolean-calculated-fields">Toggle Switch (and boolean calculated fields)</h3>

<h3 id="signature">Signature</h3>

<h3 id="file-upload">File Upload</h3>

<h3 id="date-picker-and-time-picker">Date Picker and Time Picker</h3>

<h3 id="ranking">Ranking</h3>

<h3 id="matrix--grid">Matrix / Grid</h3>

<h3 id="payment">Payment</h3>

<h3 id="fields-you-cannot-watch">Fields you cannot watch</h3>

<p>
  <strong>Schedule appointment</strong> and <strong>Documents</strong> can be visibility targets but never condition sources. A booking is
  attached to the submission rather than stored as an ordinary answer, and a Documents block collects no answer at all. Use earlier
  qualification answers to show or hide either one. Every visible Schedule appointment question must be booked before submission; a hidden
  one does not block it. See <a href="/integrations/cal-com#logic">Cal.com scheduling with logic</a>.
</p>

<h2 id="targeting">Targeting</h2>

<p>
  Each action needs a <strong>target</strong> — the thing it acts on. The target depends on the action type:
</p>

<p>
  Show and Hide reach beyond questions. Target any block on the canvas — a paragraph, heading, image, or layout container — to reveal a note
  that was hidden by default, or hide content once it is no longer relevant. They can also target individual options inside a choice field,
  not just the whole question. Hide a block from the block menu first, then write a rule to reveal it.
</p>

<h2 id="how-rules-combine">How multiple rules combine</h2>

<p>
  Every rule is independent, and they all evaluate together. Rules are read top to bottom, across logic blocks, in document order. How
  several rules on one target combine depends on the action.
</p>

<p>
  So you can point several rules at one block without them fighting. A feedback form has a Radio Buttons question — "What can we help you
  with?" — with four options, and a "Can we contact you?" email field hidden by default. Four rules each <strong>Show</strong> that same
  email field (plus their own follow-up question) for their option. The email field appears no matter which option is picked, and stays
  hidden only if none is.
</p>

> 💡 **Often one rule is enough**
> <p>
>     To reveal a block for several answers, one rule with <strong>Any</strong> and a condition per answer — or a single{' '}
>     <strong>is not empty</strong> condition to cover them all — is easier to read than four rules. Reach for several rules when each option
>     also needs its own distinct follow-up.
>   </p>

<h3 id="conflicting-rules">Conflicting rules</h3>

<p>
  When two rules disagree on the same target — one <strong>Show</strong>s a block while another <strong>Hide</strong>s it, or one makes a
  field required while another makes it optional — and both conditions match at once, the <strong>first rule wins</strong>. The later,
  losing rule is flagged in the editor: "This action never applies — an earlier rule already controls its target. Rule order decides: the
  first rule wins."
</p>

<p>
  One ordering exception: a rule whose condition reads a calculated field runs after the rule that writes it, whatever the document order,
  so a score is always computed before anything branches on it. Rules that write each other's calculated fields in a loop raise a publish
  warning that names the chain — break the loop so values resolve predictably.
</p>

<h3 id="hidden-and-required">Hidden beats required</h3>

<p>
  A question that ends up hidden is never required, whether it was hidden by a rule or hidden from the block menu with no rule to reveal it.
  The asterisk disappears and submission is not blocked — otherwise a respondent could be locked out of a form by a field they cannot see.
</p>

<h2 id="common-patterns">Common patterns</h2>

<h3 id="show-a-follow-up-question-based-on-a-previous-answer">Show a follow-up question based on a previous answer</h3>

<p>
  A satisfaction survey asks "How would you rate your experience?" with a 1-5 Star Rating. A logic block below it uses the condition "rating
  is less than or equal to 3" with the action <strong>Show</strong> targeting a Text Area field that asks "What could we improve?"
  Respondents who rate 4 or 5 never see the follow-up.
</p>

<h3 id="reveal-a-message-when-an-option-is-picked">Reveal a message when an option is picked</h3>

<p>
  A signup form has a Radio Buttons question: "Which plan fits you best?" Below it sits a paragraph — "Good choice! Our Pro plan includes
  priority support." — hidden by default with the block menu's <strong>Hide</strong>. A logic block reveals it: if plan <strong>is</strong>{' '}
  "Pro", <strong>Show</strong> the paragraph. The encouraging note appears only for Pro pickers, and stays hidden for everyone else.
</p>

<h3 id="branch-to-different-pages-based-on-a-selection">Branch to different pages based on a selection</h3>

<p>An event registration form has a Radio Buttons question: "Are you attending in person or remotely?" Two logic blocks follow:</p>

<ul>
  <li>
    <strong>Rule 1</strong> — condition: attendance <strong>is</strong> "In person", action: <strong>Set next page</strong> "Venue details".
  </li>
  <li>
    <strong>Rule 2</strong> — condition: attendance <strong>is</strong> "Remote", action: <strong>Set next page</strong> "Streaming setup".
  </li>
  <li>
    <strong>Rule 3</strong> — condition: arrival time <strong>is not empty</strong>, action: <strong>Set next page</strong> "Confirmation".
    Arrival time is a required question on "Venue details".
  </li>
</ul>

<p>
  Rules 1 and 2 read the attendance question, so they act when the respondent leaves its page. After that, Next goes on in page order. Rule
  3 reads a question on "Venue details", so it acts when the respondent leaves that page. In-person attendees then skip "Streaming setup".
  Each path collects only relevant information, then both converge on a shared "Confirmation" page.
</p>

<h3 id="calculate-a-score-and-branch-on-it">Calculate a score and branch on it</h3>

<p>
  A lead-qualification form has three Star Rating questions: budget, timeline, and authority. A calculated field named "Lead score" uses a
  logic block with the <strong>Calculate value</strong> action to add the value of each rating. A second logic block reads the calculated
  field: if Lead score <strong>is greater than 12</strong>, <strong>Set next page</strong> "Priority follow-up"; otherwise jump to the
  standard confirmation page.
</p>

<h3 id="react-to-a-hidden-field-value">React to a hidden field value</h3>

<p>
  The URL populates a hidden field named <strong>plan</strong> (e.g. <code>?plan=enterprise</code>). A logic block checks: if plan{' '}
  <strong>is</strong> "enterprise", <strong>Show</strong> the "Dedicated account manager" question and <strong>Make required</strong>
  the "Company size" field. Free-tier respondents never see these questions.
</p>

<h3 id="gate-submission-on-a-calculated-total">Gate submission on a calculated total</h3>

<p>
  An order form calculates a running total. A logic block uses the condition: if Order total <strong>is less than 10</strong>,
  <strong>Prevent submit form</strong>. The respondent cannot submit until the minimum order threshold is met.
</p>

<p>
  While a prevent rule is active, the button reads as unavailable and the respondent is told why. Type the reason into{' '}
  <strong>Message shown to respondent</strong> on the action row — "Your order must total at least 10" — so they know which answer to
  change. Leave it empty and the form falls back to "This form cannot be submitted with the current answers." (or "You cannot continue to
  the next page with the current answers." for a navigation block). When several prevent rules fire at once, the first one that carries a
  message supplies the wording.
</p>

> 💡 **Test logic with Preview**
> <p>
>     After setting up your rules, switch to <strong>Preview</strong> in the top toolbar and fill out the form as a respondent would. Logic
>     fires in real time in Preview, so you can verify every branch, hidden field, and validation gate before publishing.
>   </p>

<h2 id="next-steps">Next steps</h2>
<div class="not-prose grid gap-3 sm:grid-cols-2">
  - [Hidden fields](/building-forms/hidden-fields) — Capture URL parameters and use them in logic
  - [Calculated fields](/building-forms/calculated-fields) — Compute scores and totals with logic operations
  - [Answer piping](/building-forms/answer-piping) — Reference any answer elsewhere in the form
</div>
