Conditional logic has hit Cognito Forms! This feature allows forms to show and hide or conditionally require fields based on a respondent’s answers.
Let’s see how these features play out in the real world. Just recently, we had a user build a form for an open house event they were hosting for their customers in their three office locations. After acquiring their contact information, the first question they asked was, “Which open house are you attending?” It dawned on them – wouldn’t it be wonderful if someone attending a specific location could only see the itinerary for that event? If they are only attending one location, the rest of the form would be irrelevant! This is where conditional logic jumps in and saves the day.
Cognito Forms’ conditional logic feature consists of two main components:
- When to show a field
- When to require a field
In the example above, an open house form, the form creator wanted the respondents who were attending a specific location to be able to only fill out the questions relevant to that location. Let’s take a look at the two components and how they work together to make this vision a reality:
When to show a specific field or section
You now have four options for showing fields and sections:
- Always: This is the default choice—the field will always be shown.
- When: This is the conditional logic part—you get to decide when the field or section is shown based on the values of other fields on the form.
- Internally: This is a great way to place fields or sections that only show up internally, aka Internal Use Only, so you can track your own comments and statuses without showing these fields to respondents.
- Never: Use this to hide form fields that contain calculations that other fields will reference, or if you are pushing data into the form from another source and never want it displayed—like a tracking id, etc.
In this example, I want to show additional fields when the respondent is attending a specific open house. To do this, I would select the field that relies on the specific location answer. From here, I can select when from the navigation pane and insert my logic.
By requiring that the respondent’s answer be “Columbia, SC,” I am guaranteeing that the question I’ve applied conditional logic to for that location will only show in these circumstances. From here, I can apply the same logic to the other location sections, inserting the appropriate location into the blank. Now, when the respondent first opens the form, only the contact information, comment box, and the attending questions appear. When a specific location is selected, the remainder of the form will magically appear – it’s that simple!
When to require a specific field type
There are three options for requiring fields:
- Always: Select this choice if you want all respondents to always be required to provide an answer. Fields will only be required when the field is visible.
- When: Specifies that you want the field to be required based on other field values.
- Never: This is the default selection. Never should be selected if you want to make the field optional for the respondent to answer.
The second half of our customer’s problem pertained to requiring answers to specific fields. How can he require an answer for all fields for only those who are attending a specific location of the open house event? This is where conditional logic comes into play. In this case, we would select the fields we want to be required and use the Always type.
Our logic is slightly different than before. We want to require a question to be answered when the respondent is attending a specific location of our event. Requiring answers from only those attending a location allows those who are attending a different location to quickly submit the form, avoiding irrelevant questions and ultimately saving time. The Always selection applies only to form fields that are visible to the respondent. This way, you can require all form fields to be required, ensuring that fields for a specific location will be filled out completely.
Within the form, the builder asks the question, “Will you be joining us for lunch at 11:30?” He also asks which lunch choice the attendee would like. If an attendee is not attending lunch, the second question is irrelevant. We can use the When conditional logic to ensure that only those attending lunch will be asked to fill out their lunch option.
Using the same logic, we can make the lunch option question only required when the respondent is attending lunch.
Conditional logic is an advanced feature nested inside Cognito Forms. With conditional logic, the form creator can easily show/hide fields and require fields based on a respondent’s answer. The combinations are endless. Give it a try today. We love receiving feedback from our valued customers! Leave a comment below if you have any questions regarding conditional logic or have a feature you would love to see!