Skip to content

Conditional logic

Two things in a form take conditions: a field, which decides whether it shows, and a notification, which decides whether it sends. They use the same editor and the same operators.

Show when — conditions on a field

Select a field and open Show when. Add rules, each naming another field, an operator, and a value.

SettingWhat it does
Matchall — every rule must pass. any — one is enough
RulesField, operator, value

The form hides and shows fields as the visitor types. Nothing is submitted, nothing reloads.

The ten operators

OperatorPasses when
isThe value equals yours — for a multi-value field, when any of its values does
is notNo value equals yours
containsSome value contains your text
does not containNo value contains your text
is emptyNothing is filled in
is not emptySomething is filled in
greater thanThe value is a number greater than yours
less thanThe value is a number less than yours
is checkedA switch or consent box is on
is uncheckedA switch or consent box is off

Text comparison ignores case and surrounding spaces, so Support matches support.

The server checks again

Conditions are evaluated twice: once in the browser so the form behaves, and once on the server against the values actually submitted.

That second pass is what makes conditions trustworthy. A field whose condition does not pass is neither required nor saved, whatever the browser sent. A visitor who reveals a hidden input and fills it in has not slipped a value past you; a visitor whose browser fails to run the script is not blocked by a required field they were never meant to see.

Examples

GoalRules
Ask for a company name only from businessesAccount type is business
Ask why only when the answer is noAre you happy? is unchecked
Ask for shipping details only above a valueOrder total greater than 100
Ask for a phone number when there is no emailEmail is empty
Show a warning for two of five optionsMatch anyPlan is enterprise, Plan is custom

Chains work, loops do not

A field can be conditioned on a field that is itself conditional — the chain resolves in order. What it cannot do is depend on itself, directly or in a circle.

Send when — conditions on a notification

Each email notification can carry its own conditions under Send when. Same editor, same operators, evaluated against the submitted values.

That is how one form routes itself: a Department dropdown with three choices and three notifications, each conditioned on one choice, sends every inquiry to the right inbox without a plugin in between.

Conditions combine with When it sends — a notification set to send on approval with a condition sends only when the account is approved and the condition passes.

Notes and limits

  • A rule names a field by key. Removing a field that a rule points at leaves the rule pointing at nothing; it never passes. Clean up rules when you delete fields.
  • Conditions compare against values the visitor entered, not against the post that ends up being saved.
  • Conditions on the layout blocks — heading, text, HTML — are not applied on the front end; those blocks always show. Put conditional explanation in a field's help text, or split the form.

Built by Code Wattz.