When a validation condition is triggered, a warning icon (flag) appears next to all of the question(s) used in the expression. Placement and display of the flag can be customized with the
flag
tag.
single question flag
validation: !(anyChecked($Q1,2) and anyChecked($Q2,2))
message: You said you both like and dislike sunshine when running outdoors. Please explain why.
flag: Q2_WHY
multiple questions flag
validation: !(anyChecked($Q1,2) and anyChecked($Q2,2))
message: You said you both like and dislike sunshine when running outdoors. Please explain why.
flag: Q1, Q2, Q2_WHY
Details
- TheĀ
flag
tag is placed on avalidation
widget on an independent line. - The
flag
tag accepts a question ID or a custom variable as input. For survey questions, use the question ID with a leading "Q" (e.g.,Q1
). For custom variables to relocate the flag, prepend the ID with$
(e.g.,$QCUSTOMVAR
). - Multiple questions/variables can be used as input. List the IDs in a comma-separated format.
-
Create a custom location for the flag by defining a custom variable and placing it where you want the flag to appear. Use the variable in the
flag
tag to reference the custom location. - Insert the flag directly into the validation message using
{[icon]}
.
Additional examples
Reducing the number of displayed flags
As mentioned above, when a validation condition is triggered, a flag appears next to all of the question(s) used in the expression. The flag
tag can be used to reduce the number of warnings shown on screen to help the respondent focus on the specific field where attention is needed.
In the example below, the flag would normally appear next to Q1 and Q2. However, it would be more effective for the respondent to see the flag next to the "why" follow-up question Q2_WHY.
1. What do you <u>like</u> about running outdoors?
type: checkbox
randomize: y
1. Fresh air
2. Sunshine
3. Improve mental health
4. Variety of environments
5. It's free
2. What do you <u>dislike</u> about running outdoors?
type: checkbox
randomize: y
autopage: n
1. Mosquitos
2. Sunshine
3. Weather can impact the training
4. Have to purchase different shoes
5. Can be lonely
why: Why do you dislike the sunshine? {showif: anyChecked($Q2,2)}
validation: !(anyChecked($Q1,2) and anyChecked($Q2,2))
message: You said you both like and dislike sunshine when running outdoors. Are you sure? Please click the arrow button again to continue.
warn: y
flag: Q2_WHY
Creating a custom location
To create a custom location for the flag, create a custom variable and reference that variable on the page. The custom variable is not available in the reports and is only used for relocating the flag.
In the example below, the flag variable is defined as '$Q4FLAG' and is inserted at the end of the question text. To trigger the validation, either enter '0' for the first three rows, or leave them blank.
Using the warning icon in messages
In the message
tag of any validation, {[icon]}
can be included to insert the flag icon in a specific place in the message text, as shown below.
validation: if (anyChecked($Q1,1..3)) {$Q2 ne ''} else {1}
message: Please answer all questions marked with the {[icon]} icon.
Note: At this time, flag
can be used with all themes other than Flex.
Comments
0 comments
Please sign in to leave a comment.