Conditional logic
A condition shows a field, or a whole section, only when the visitor’s other answers match rules you set. Everything else about the field stays the same; it simply appears and disappears as the visitor fills in the form.
When to use it
Section titled “When to use it”- A follow-up question that only applies to one answer: “Other — please specify”.
- A group of questions for one kind of enquiry, in a section that appears when that kind is chosen.
- Conditions change only what is shown. To email different people depending on an answer, see Email notifications.
How to add a condition
Section titled “How to add a condition”Add conditions to the field or section that should appear. It holds a list
of rules and how they combine:
{ "key": "other_detail", "type": "text", "label": "Please specify", "required": true, "conditions": { "logic": "and", "rules": [ {"field": "service", "operator": "equals", "value": "other"} ] }}fieldis the key of the field to check.valueis compared with the stored value of an option, not its label.logicisand(every rule must match, the default) oror(any rule).
The form re-checks the rules as the visitor types and chooses.
Operators
Section titled “Operators”| Operator | Shorthand | Matches when the checked field… |
|---|---|---|
equals | ==, = | is exactly value |
not_equals | !=, <> | is anything but value |
contains | — | contains value, ignoring case |
not_contains | — | does not contain value, ignoring case |
is_empty | empty | has nothing entered or chosen |
is_not_empty | not_empty | has something entered or chosen |
is_checked | checked | is a single tick box that is ticked |
is_not_checked | not_checked | is a single tick box that is not ticked |
greater_than | > | is a number larger than value |
less_than | < | is a number smaller than value |
greater_than_or_equals | >= | is a number at least value |
less_than_or_equals | <= | is a number at most value |
in | — | is one of the values in a list: "value": ["a", "b"] |
not_in | — | is none of the values in a list |
An operator the form does not recognise counts as matching.
What happens to a hidden field
Section titled “What happens to a hidden field”- It is not required while hidden. The visitor can submit without it.
- Its value is thrown away on submission, so it does not appear in the entry, the notification email or the webhook, even if the visitor typed something before it was hidden.
- The server checks the rules again on submission; it does not rely on what the browser showed.
Limits and common problems
Section titled “Limits and common problems”- Checking a checkbox group. For a group where several boxes can be
ticked, use
contains(true when any ticked value containsvalue),is_emptyoris_not_empty.equalscompares one value and never matches a group. Use radio buttons or a dropdown when a condition needs exactly one chosen value. - The condition never matches. Check that
fieldis the field’s key, and thatvalueis the option’s value rather than its label.