Conditional Logic for Fields

Show or hide a form field based on another field's value, whether the visitor is logged in, or the page the form is on.

Free & PRO Last reviewed

Conditional Logic shows a field only when the conditions you set for it are met. Use it when a field matters to some visitors and not others — company details only for business customers, a callback time only for people who asked to be called.

Conditional Logic is available in Elzo Forms Free and PRO. PRO adds further condition types, covered in Advanced Conditional Logic in PRO.

Add a condition to a field

  1. Open the form in Forms and go to the Fields tab of the Form Data box.
  2. Expand the field that should appear conditionally.
  3. Open its Logic tab and tick Conditional Logic.
  4. Under Show this field if, click the condition type button and pick a type, then choose the field to compare, an operator, and a value.
  5. Update the form, then reload the page it is published on and try both answers.

The condition is attached to the field that should appear, not to the field that triggers it. To show Company name when Customer type is Business, you configure the condition on Company name.

The condition type button opens a searchable list of types. Type a few letters to filter it, move with the arrow keys and press Enter, or click a type; Escape closes the list without changing anything.

The field list inside a Field value condition covers every field in the form, across all steps, and follows your edits as you make them — a field you have just added, renamed or retyped is selectable straight away, without saving first.

How conditions are combined

Conditions are arranged in groups.

Inside one group, rules are joined with and — every rule has to be true. The and button adds another rule to the same group.

Add rule group creates a second group, and groups are joined with or. Elzo Forms checks the groups from top to bottom and shows the field as soon as one group is completely true.

So “show this field if the customer type is Business, or if the order total is over 1000” is two groups of one rule each, while “Business and over 1000” is one group of two rules.

Grouping is also how you build a range, since no operator takes two bounds. Two rules in one group give you “between”: greater than 100 and less than 500 on a Range field, or, with PRO’s Date and Time type, is after the opening date and is before the closing one. Both bounds are exclusive, so widen them by a minute or a unit if the edge should be included. For the inverse — outside a range — put the two rules in separate groups so either one is enough.

A field whose conditions never match stays hidden. Leave Conditional Logic unticked until the rules are complete, or the field disappears from the form.

Condition types

Condition type Compares Available in
Field value The current value of another field in the form Free & PRO
Authentication Whether the visitor is logged in to WordPress Free & PRO
Page The page the form is displayed on Free & PRO
URL The address of the current page PRO
User The current user’s role or ID PRO
Cookie A cookie in the visitor’s browser PRO
Date and Time The current moment against a date and time PRO

In Elzo Forms Free the type list also shows the PRO types, in a separate Elzo Forms +PRO group where each is marked PRO. Choosing one opens a short description of those types instead of adding the condition.

An Authentication condition takes no value: its two operators, is logged in and is guest, are the whole rule.

Conditions whose type is not available

A form can hold conditions of a type the site cannot check at the moment — PRO conditions after Elzo Forms PRO has been deactivated, for example, or conditions added by another plugin that is switched off. Elzo Forms keeps such a condition when the form is saved and shows a notice under it: Requires Elzo Forms +PRO. The condition is kept, but counts as not met until PRO is active.

Until its type is available again, the condition counts as not met, in the browser and on the server alike, so a group that contains it never matches. Once the plugin that adds the type is active again, the condition works as before.

Page conditions

A Page condition compares the post the form is displayed on, which makes one form behave differently depending on where it is embedded.

Operator The condition is true when
page ID equals The form is on the page you picked
page ID not equals The form is on any other page
page ID in list The form is on one of the pages you picked
page ID not in list The form is on none of the pages you picked
post type is The current post is of the post type you picked
post type is not The current post is of any other post type
post type in list The current post is of one of the post types you picked
post type not in list The current post is of none of the post types you picked

You do not type IDs or slugs. For the page ID operators, the value box searches your site’s content: click it to see the most recent entries, or type at least two characters of a title. page ID equals and page ID not equals take one entry; the in list operators take several, each shown as a chip you can remove. Entries of any public post type can be picked — pages, posts, products. Drafts, private and scheduled entries are offered only when you are allowed to edit them.

post type is and post type is not show a dropdown of the site’s public post types; the in list operators let you pick several.

If a page you picked is deleted later, or a post type stops being registered, the condition keeps it and marks it unavailable instead of dropping it, so saving the form does not quietly change the rule. Remove it yourself once it no longer applies.

Note: archives, search results and the blog index have no single post behind them, so a form placed there reports no page ID and no post type. page ID equals, page ID in list, post type is and post type in list cannot match on those views.

Operators

These are the operators a Field value condition offers. The other condition types bring their own, listed with each type.

Operator The condition is true when
is The field’s value is exactly the text you entered
is not The field’s value is anything other than that text
contains The value contains that text anywhere
does not contain The value does not contain that text
starts with The value begins with that text
ends with The value ends with that text
matches pattern The value matches the regular expression you entered
greater than The value, read as a number, is larger than the one you entered
less than The value, read as a number, is smaller than the one you entered
number of values is The field submitted exactly as many values as the number you entered
number of values is greater than The field submitted more values than that
number of values is less than The field submitted fewer values than that

Comparisons are exact, including letter case: Business does not match business.

The operators on offer depend on the field the condition reads:

  • Text, Textarea and Hidden fields offer every operator except the number of values ones.
  • Select, Radio and Checkbox fields compare as text and drop greater than and less than.
  • A Checkbox field, and a Select field with Allow multiple selections, also offer the number of values operators.
  • A File Upload field offers is, is not, contains and does not contain, plus the number of values operators when Allow multiple files is on.
  • A Range field offers only is, is not, greater than and less than.

matches pattern takes a regular expression without surrounding slashes — ^ACME-[0-9]+$, for example. A pattern that is not valid never matches. Use it only when the simpler operators cannot express the rule.

Comparing option fields

Choose is or is not on a Select, Radio or Checkbox field and the value box turns into a dropdown of that field’s options. It shows each option’s label but stores its value, which is what the comparison actually uses.

With any other operator the value box stays a text box, and you have to type the option value yourself — again the value, never the label. Option values and labels are explained in Field Types Overview.

Comparing fields that hold several values

A Checkbox field, a Select with multiple selections, and a File Upload field with multiple files all hold a list. The value operators treat a list like this:

  • is, contains, starts with and ends with are true when at least one of the values matches.
  • is not and does not contain are true only when none of the values matches.
  • matches pattern, greater than and less than are true only when every value matches.

A field with nothing selected compares as an empty value, so is not against any real option is true while the visitor has chosen nothing.

The number of values operators answer a different question: how long the list is. They take a number and count only what was actually submitted, so a field with nothing ticked, selected or uploaded has zero values. “Show this field when more than two topics are ticked” is number of values is greater than 2.

Comparing File Upload fields

A File Upload field compares against the address of each uploaded file. Elzo Forms stores files under a random name but keeps the extension, in lower case, so contains .pdf is true once a PDF has been uploaded. The original file name is not part of the address and cannot be matched.

Leave the value empty to ask whether a file was uploaded at all: is not with an empty value is true once the field holds a file, and is with an empty value is true while it holds none.

When conditions are evaluated

In the browser, conditions are evaluated when the page loads and again whenever a field that a condition reads is changed. Changes are picked up on the browser’s change event, so a text field is re-checked when it loses focus rather than on every keystroke, while a dropdown or a radio button reacts immediately. A File Upload field is re-checked when a file finishes uploading and when one is removed.

The same rules are evaluated again on the server when the form is submitted, against the values actually sent. That second pass is what decides which values are stored, so a visitor cannot reach a hidden field by editing the page.

What happens to a hidden field

A field hidden by conditional logic is removed from the submission entirely:

  • Its value is not saved, even though the input is still present on the page.
  • Its Required setting is not enforced, so a hidden required field never blocks a submission.
  • It does not appear in the notification email, in the Submissions screen, or in any automation.

A condition can read a field that is itself hidden. A hidden field keeps whatever value it had, in the browser and in the submitted data, so conditions chained across several fields behave the same in both places.

Note: fields with conditional logic are hidden in the page HTML and revealed by JavaScript. If a visitor has JavaScript disabled, or a caching or optimisation plugin blocks the Elzo Forms script, those fields never appear.

Example

A quote form asks who is requesting the quote, and needs company details only from businesses.

Add a Radio field labelled Customer type with these options:

private : Private person
business : Business

Add a Text field labelled Company name, open its Logic tab, tick Conditional Logic, and set the rule to:

Field valueCustomer typeisBusiness

The dropdown displays “Business” and stores business, the option’s value. Company name now appears only when the visitor selects Business, and only Business submissions carry a company name.

To also ask for a VAT number from anyone whose country is Germany, add a second rule to the same group (both conditions must hold) or a second group (either condition is enough).

Limitations

  • Conditions control visibility only. They do not change a field’s own validation — a visible field is validated normally, a hidden one is skipped.
  • Conditions cannot be set on a whole step. To skip a step, restructure the form; see Multi-Step Forms.
  • A condition compares against a single value you enter, not against another field.

A Field value condition resolves within the form it belongs to before looking anywhere else, so publishing the same form twice on one page keeps each copy’s logic independent.

Troubleshooting

The field never appears

Check the compared value first. For Select, Radio and Checkbox it must be the option value, not the label, and the comparison is case-sensitive. For a Page condition, check that you picked the page the form is actually on, and that the form is not on an archive or search page, which have no page ID. Remember that every rule in a group has to be true — split rules into separate groups if either one should be enough.

The field appears, but its value is missing from the submission

The conditions matched in the browser but not on the server. Both sides evaluate the same rules against the same context, so this points at something that changed between rendering and submitting — a field another script rewrites after the page loads, or a Date and Time condition that elapsed while the visitor was filling the form in.

The field does not react while the visitor types

Text and Textarea fields report their value on the browser’s change event, which fires when the field loses focus. If the field has to react sooner, drive the condition from a Select or Radio field instead.

Every conditional field is missing on the live page

The Elzo Forms script is not running. Check the browser console for errors, then check any caching, minification or script-deferral plugin — conditional fields start hidden and depend on that script to appear.

Next steps