Cognito Forms logo

Conditional logic

Conditional logic makes viewing your form an easier, more intuitive task for your users. Whether you want to show or hide certain fields and pages, allow your users to pay when they want, send emails to people at specific times, or conditionally require a field, there are endless possibilities to make your form look better and flow more efficiently.

Common uses of conditional logic include:

1. Showing and hiding fields or sections

2. Showing pages on multi-page forms

3. Email routing

4. Requiring payment

5. Requiring fields

6. Validating fields

Showing and hiding fields or sections

Sometimes, certain questions may on your form may require additional information. But, you'd rather not overwhelm your users with a bunch of extra fields that they don't need to complete. With some simple conditional logic, you can automatically show and hide fields or sections depending on what the user selects. To show and hide fields:

  • Go to the field you're trying to show and hide, and look for the Show This Field section in the field settings box:

  • Next, set the conditions under which your field will display. In this case, we want a field labeled "Please explain" to appear if the user answers "No" to the question "Were you satisfied with our customer service?"

  • Now, when the user selects No, another field will appear to ask them to explain further. If they answer Yes, they won't see the extra field at all, and they can simply continue on with the rest of the form.

Showing pages on multi-page forms

When your form has a lot of pages, you don’t want to confuse your users by showing them pages they may not need. Usually that would mean you’d need to build a separate form, which takes too much time and separates related data. With conditional page branching, you can send each of your users on a completely different path depending on what they answer. To conditionally show a page:
  • Add a page break, then select When from the Show Next Page section in the field settings.

  • In the conditional logic builder, you can set the page to only be visible when the user selects a specific option in the Choice field:

  • Now, the "Sales Director" page only appears when the user selects Sales Director from the drop-down list:

Learn more about multi-page forms.

Email routing

The ability to create more than one email notification is available to organizations on the Pro, Team, or Enterprise plans.

Control who gets notified and when with email routing. For example, set notification emails for a contact form to send to different people depending on the department the user selects. Or, send a confirmation email to update your users when their submission has been approved. To set conditional notifications:

  • From the Submission Settings section in your form builder, select either Notification Emails or Confirmation Emails.

  • For this example, we're going to send the sales department a notification whenever a job applicant selects "Sales" as their desired position. In the notification email dialog, we can specify who's receiving the email, the subject of the email (with the Name field inserted), and a custom message accompanying the link to the full application.

  • On the right, you can choose between the "Send When Submitted" and "Send When Updated" options. "Send When Submitted" will send emails when an entry is submitted, while "Send When Updated" will send emails when an entry administrator edits and saves an existing entry. Here, we're just going to specify that the email is sent only when the selected department is Sales.

Conditional Email Routing







Learn more about email routing.

Requiring payment

Require payment now or laterDetermine the circumstances in which your customers are required to pay. If you want to give your customers the option to pay now or later, simply add a choice field with conditional logic. When they select Pay Now, the payment will become required. When they select Pay Later, they can just submit their order without payment.

Requiring fields

Set your fields as always, never, or sometimes required under specific conditions to make sure you get your data when you need it. For example, when a user specifies that they would like to pick up their delivery, create a Phone field so you can notify them when their order is ready – and the field is only required and appears when they choose Pick-up. To require a field:

  • Go to the field settings box of the field you want to require, and find the "Require This Field" option.

  • Set the the conditions under which the field needs to be required.

Conditionally require fields





  • Now, along with the "Show This Field" options, the Phone field will only appear and be required when the user selects "Pick-up".

Validating fields

With the Custom Error option (located in the settings area of almost every field type), you can specify certain conditions that will cause a custom error message to display underneath a field. Using both advanced and conditional logic, you can add any number of rules for validating your fields. To set your own custom error rules:

  • Select the field you want to validate, then find the "Show Custom Error" option at the bottom of the field settings box.

  • After the conditional logic builder appears, set the conditions under which you want your field to result in an error. In this example, we don't want our users to enter a website address that doesn't contain a .org domain name.

  • After we've set our conditions, we can write our own custom message in the second box:

  • Now, when the user tries to enter a website address with a domain that isn't .org, they'll see a custom error message:

Learn more about the Custom Error option.

Printable View