Using conditional logic and validation for forms

Get ready to level up your Forms! We'll show you how to add conditional logic to make your forms smarter, implement validation to ensure accurate data, and seamlessly create attributes in the Hub for better data organization. Let's take a look!

Adding conditional logic

To add conditional logic to your form, select LOGIC & VALIDATION in the bottom right-hand corner of your question block.

Questions with Condition Logic can't be required
If a question has a conditional logic rule, it cannot be required. Trigger questions can be required.

"Conditional logic" lets you add rules that change whether a question is seen by the responder, or hidden from display, based on the answer to a "trigger question" earlier in the form. For example, you could hide one or more questions related to in-store experience, if the respond answered an earlier question to say that they shopped online.

Let’s take a look at some more examples in the Forms. 

We’ll start simple, our first example shows an NPS survey. The user will indicate on the 0-10 scale how likely they are to recommend Fitness Co to someone. 

Let’s assume you'd like to add a follow up question to ask for more information, but you want the user to see a different question depending on the score they give. This is where conditional logic really shines. 

There are two potential outcomes with the conditional logic we have set up:

  1. If they select equal to or less than 5, “We're sorry to hear that you had a negative experience. What could we do to improve?” will be visible. 
  2. If they select equal to or greater than 6, “We're so happy to hear you've had a positive experience. Could you tell us where we could improve?” will be visible. 

The outcome, one question will be hidden and the other visible depending on the score given. If the user rated their likelihood to recommend Fitness Co a 7, they would only see the “We're so happy to hear you've had a positive experience. Could you tell us where we could improve?” question. 

Let’s take a look at another example. 

This example is attempting to collect specific product feedback to inform future design decisions. You can see the parent question “What was your more recent purchase? pick a category”. Based on the selection, questions will be hidden or visible. If they select “Tops” for example the user will see a question asking for feedback on the Top they purchased, all other questions have been hidden. 

There are a multitude of ways you can utilise conditional logic in forms to create wonderfully simple user journeys through a survey. Get creative and if you are having trouble please reach out to your Success Manager or support@lexer.io.

Adding validation

To add validation to your form, again, select LOGIC & VALIDATION in the bottom right-hand corner of your question block.

Validation allows you to set rules around what kind of inputs will be accepted by your form. For example, the email address field requires answers to contain @ and .com before the answer will be accepted. If the answer doesn’t contain these validators then an error message will appear.

Date and Date of Birth questions support age-gating validation options. You can restrict submissions to users who are "older than" a particular age, for example 18 or 21. This validation is dynamic and will calculate the responder's age based on the date they are submitting the form.

Here you’ll also find the attribute associated with this question. All responses to this question will populate this attribute in your Lexer CDP, making it available for insights and segmentation.

This section will either display the new attribute that will be created from this question, or the standard attribute that the data from this question will flow in to.

What's next?

Lexer’s Form Builder is the ultimate way to create forms and surveys to capture zero-party data directly from your customers. To learn more about access and pricing, you can find more detail here. If you would like any help, reach out via the chatbot in the bottom right hand side of the page. We have heaps more content that showcases Lexer's Form Builder. You can see the full list of Forms content here.

Updated:
August 1, 2024
Did this page help you?
Thank you! Your feedback has been received!
Oops! Something went wrong while submitting the form, for assistance please contact support@lexer.io