How to Add Conditional Logic to a Divi Contact Form

Show and hide Divi 5 form fields based on each visitor's answers, step by step, with no code.

HappyDivi Form conditional logic tutorial for Divi 5, showing a form with conditional fields

To add conditional logic to a Divi contact form, open the field that should appear or disappear, turn on Conditional Logic, and add a rule such as show this field when Type of Event is equal to Wedding. Repeat for each dependent field, then test the form on the live page.

Long forms scare people off, and most visitors only need some of your fields. With conditional logic, someone planning a wedding sees guest count and venue, while someone booking a corporate event sees company name and VAT number. The form stays short and you still get the details you need.

This guide builds that exact form in the Divi 5 Visual Builder with HappyDivi Form, a native form module where showing and hiding fields is free. Every screenshot comes from a real test form on Divi 5.15.1 and HappyDivi Form 1.0.4.

Do You Need a Plugin for This?

Not always. Divi 5's own Contact Form module already has conditional logic, with match-all or match-any rules. If you only need to show and hide a few fields, and an email is all you need from each submission, it may be enough.

A dedicated form module earns its place when you also want every submission saved in WordPress, or the rest of the form to react to answers: different recipients, different thank-you messages, different email text. The comparison table below shows the differences.

Step 1: Add the Form and a Trigger Field

Add a HappyDivi Form module to your page in the Visual Builder. You can start from a blank form or import a ready-made template.

Then add the field that decides what comes next. This is your trigger field, and it is usually a Select Dropdown or Radio Buttons field. For our example:

  1. Add a field and set Field Type to Select Dropdown.
  2. Set Field Label to Type of Event and Field ID to event_type.
  3. Open the Select Options group and add Wedding, Corporate and Birthday.
HappyDivi Form Select Options group in the Divi 5 settings panel with Wedding, Corporate and Birthday options

The trigger field's choices are set in the Select Options group.

Pro tip

Keep the trigger field near the top of the form. Visitors make the big choice first, and everything after it is already tailored to them.

Step 2: Add the Fields That Depend on It

Now add the fields only some visitors need. Our form has four: Number of Guests and Preferred Venue for weddings, and Company Name and VAT Number for corporate events.

Give every field a unique Field ID. Rules can only point at fields that have one, and only at fields inside the same form.

Step 3: Add a Rule to Each Dependent Field

Open a dependent field, such as Number of Guests, and go to Content tab → Conditional Logic. Then:

  1. Turn on Enable.
  2. Set Action to Show this field. You can choose Hide this field instead.
  3. Leave Match on Any rule if you have one rule.
  4. Under Rules, pick event_type: Type of Event, then is equal to, then Wedding.

Repeat for each dependent field. The two corporate fields use the same rule with Corporate as the value.

Conditional Logic settings in the Divi 5 Visual Builder with the rule event_type is equal to Wedding

A complete rule: show this field when Type of Event is equal to Wedding.

Tip

The Rules row is tight at the default panel width, and its values get cut off. Drag the edge of the settings sidebar to widen it and you can read the whole rule.

Step 4: Check the Form in the Builder

The Visual Builder keeps every field on screen so you can still edit it. Fields with rules show a purple CONDITIONAL badge instead of disappearing, so seeing them all here is normal.

Divi 5 Visual Builder showing a HappyDivi Form with CONDITIONAL badges on four dependent fields

In the builder, the CONDITIONAL badge marks each field that has a rule.

Step 5: Test Every Path on the Live Page

Save the page and open it in a new tab, because the show and hide behavior runs on the real page. Choose each answer in turn and check the right fields appear.

Divi contact form on the live page with Wedding selected, showing Number of Guests and Preferred Venue fields

Choosing Wedding reveals Number of Guests and Preferred Venue.

The same Divi contact form with Corporate selected, showing Company Name and VAT Number fields

Choosing Corporate swaps them for Company Name and VAT Number.

Then submit one test entry per path and open it under HappyDivi Form → Entries. We submitted a Birthday enquiry, which has no extra fields. It went through even though all four hidden fields were marked required, and the entry saved only the fields the visitor could see.

HappyDivi Form entry screen listing only Your Name, Email Address, Type of Event and Tell Us More

The saved entry contains only the fields the visitor could see.

All 10 Rule Conditions

Each rule compares another field's answer using one of these conditions:

ConditionUse it for
is equal toAn exact answer, such as Wedding
is not equal toEvery answer except one
containsPart of an answer, such as a word in a text field
does not containAnswers without a given word
starts withCodes or prefixes
ends withEndings, such as an email domain
is emptyA field the visitor skipped
is not emptyA field the visitor filled in
is greater thanNumeric fields only, such as guests over 50
is less thanNumeric fields only, such as budgets under 1,000

When a field has several rules, Any rule shows it when one rule passes, and All rules needs every rule to pass. Rules also work with checkbox groups and multi-select fields, where each selected value is checked.

What Happens After the Form Is Sent

Field rules decide what visitors see while they fill in the form. HappyDivi Form can also change what happens afterwards.

Free:

  • Merge tags: reuse answers in your text. With our form, Thanks %%field_your_name%%! greets the visitor by name.
  • A formatted success message: use links, bold text and lists, not only plain text.
  • A choice of success action: show a message, redirect to a page, or show a message and then redirect.

Pro:

  • Conditional notifications: add as many notification emails per form as you need, each with its own recipient and conditions. Send Sales enquiries to Sales and Technical ones to Support.
  • Success Rules: show a different message or redirect depending on the answers, such as a booking link only for wedding enquiries. The first matching rule wins.
  • Conditional content: write {{if event_type is "Wedding"}}...{{else}}...{{/if}} inside email subjects, email bodies or success messages.

Divi Contact Form vs HappyDivi Form

FeatureDivi Contact FormHappyDivi Form FreeHappyDivi Form Pro
Show or hide fieldsYesYesYes
Match any or all rulesYesYesYes
Rules checked on the serverYesYesYes
Starts with and ends with conditionsNoYesYes
Entries saved in WordPressNoYesYes
Conditional notification emailsNoNoYes
Different success message per answerNoNoYes

We checked Divi's column against the Divi 5.15.1 code. Divi can also change, so check its current release if this decision matters for your project.

Four Conditional Forms Worth Building

  • Department contact form: "What is this about?" shows order number for Orders, website URL for Support and budget for Sales.
  • Event registration: "Will you attend the dinner?" reveals meal choice and dietary needs only for people who say yes.
  • Quote calculator (Pro): choosing a package reveals its add-ons, and a Calculated field shows the running total. Add Stripe and the visitor can pay a deposit: see Stripe payments with a Divi form.
  • Job application (Pro): the chosen role reveals the questions for that role and a file upload for a portfolio.

Conditional Logic Not Working? Check These

The Field I Want Is Not in the Rule Dropdown

The field needs a unique, non-empty Field ID and must be in the same form. Check its Field Settings group.

All My Fields Show in the Builder

This is expected. The builder keeps them visible and marks them with a badge. Test on the live page.

The Field Never Appears on the Live Page

Check that Enable is on and that the rule's value matches the option's text. If you renamed an option after writing the rule, pick the value again. Also check Match: with All rules, a single failing rule keeps the field hidden.

A Greater Than Rule Is Missing

Is greater than and is less than are only offered when the rule points at a numeric field.

Frequently asked questions

Does the Divi Contact Form module have conditional logic?

Yes. Divi's own module can show and hide fields with match-any or match-all rules. It does not save submissions in WordPress, and it does not offer conditional notifications or per-answer success messages.

Is conditional logic free in HappyDivi Form?

Yes. Showing and hiding fields with rules is in the free version. Conditional notifications, Success Rules and conditional email content are Pro features.

Will a hidden required field stop the form from sending?

No. Hidden fields are left out of validation, so a required field only counts when the visitor can see it. We tested this by submitting a form with four hidden required fields empty, and it went through.

Can someone force a hidden field through by editing the page?

HappyDivi Form runs the same rules again on the server when the form is submitted, and hidden fields are not saved, so changing the page in the browser does not add them to the entry.

Why do all my conditional fields show in the Visual Builder?

The builder keeps them visible so you can edit them, and marks each one with a CONDITIONAL badge. Open the saved page to see them show and hide.

From HappyDivi

HappyDivi Form

Saves every entry inside WordPress, so a lead never depends on an email arriving.

  • 22 field types, multi-step forms and conditional logic
  • Native Divi 5 module

Free plan available

From HappyDivi

HappyDivi Form

Saves every entry inside WordPress, so a lead never depends on an email arriving.

  • 22 field types, multi-step forms and conditional logic
  • Native Divi 5 module

Free plan available

Get the next Divi 5 guide

New guides and plugin news from HappyDivi. Unsubscribe any time.

Rubait Hasan

Written by

Founder & Product Builder

Rubait has been building for Divi since 2017. He founded DiviZoom in 2019, sold it in 2022, and started HappyDivi when Divi 5 rebuilt the builder from the ground up. He writes the code behind HappyDivi's plugins and answers support himself.

More articles by Rubait