Sometimes in surveys, you may want to prevent a participant from proceeding based on their response to a survey question. This can be accomplished by configuring survey validation logic.
There are two types of validation within MyDataHelps Designer - rules and patterns. Validation rules are set via the Validation tab and apply to an entire survey step, whereas validation patterns are set within the Properties tab of a survey step and are specific to single questions within the step.
Validation rules can be particularly useful in the context of eligibility screening or consent surveys, in which you might not want a participant to proceed unless they satisfy various eligibility criteria.
Adding Validation Rules
To set up validation for a step in the survey editor, go to the validation tab for the step you would like add validation for. Note that you cannot add validation rules to the last step of your survey.
Validation rules are set up similarly to navigation rules and use the same conditional editor.
When you have selected the validation tab for a particular step, click the “Add Validation Rule” button to start adding a validation rule.
You can then set up a condition. For instance, if the step “
IS_OVER_18” has the answer “NO,” you can then enter a message to be displayed if the condition evaluates to true—for example, “You must be over 18 to participate in this study.”
You can set up as many validation rules as you want on a single step. When a participant completes this step, the validation rules will be evaluated in order until one evaluates to true, in which case the message for that rule will be displayed. If none of the validation rules evaluate to true, the participant will be allowed to continue to the next step.
You are not restricted to a single conditional when editing a validation rule. By clicking the “AND”, “OR,” and “NOT” buttons you can combine or negate the various conditions.
Validation patterns allow study teams to prevent participants from entering faulty data into text answer format questions, thereby reducing the amount of data cleaning required prior to analysis. Common examples include not allowing numbers in a response (e.g., names and cities) or requiring a certain answer format (e.g. phone number with dashes).
To use validation patterns, go to the survey page and click into the survey where you would like to add a validation pattern. Go to the Properties tab.
Scroll down and add one the following strings to the "Validation Pattern" field. Next, add text in the "Invalid Pattern Message" field - the text you add here will be shown to participants if they enter invalid data.
Validation patterns only work when the text answer format and require that you specify an "Invalid Pattern Message."
|A study team wants to restrict answers to letters and characters only to prevent faulty data. This string allows for special characters (e.g. O'Connor or Martha's Vineyard), but no numbers.
|Data managers want participants to enter phone numbers in the same format to make data analysis easier (e.g. 555-888-7777).
|Study coordinators want to ensure participants are entering valid email addresses.
Note: Add this string before any other validation pattern for optional items. For example, optional phone number:
|As a PI, I want to leave contact informational optional, but if a participant decides to add their phone number make sure it is entered in a valid format.
For a tutorial on developing and using validation patterns, visit RegexOne.