The row validation
and column validation
tags (alias row validate
and column validate
) extend the functionality of the validation
tag specifically for tables. These tags apply custom restrictions to every row or column. The validation tags check a logical condition and prevent the respondent from proceeding to the next page if the condition is not met.
row validation
10. Please select up to two attributes you feel most exemplify each brand. type: checkbox table row validation: countChecked($Q10R[id]) <= 2 { message: Please do not select more than 2 attributes for [text]. } 1. Texture 2. Saltiness 3. Nutty flavor 4. Consistency 5. Aroma rows: 1. Skippy 2. Jif 3. Peter Pan 4. Planters 5. Store brand
column validation
11. Please select up to two attributes you feel most exemplify each brand. type: checkbox table vscale: y column validation: countChecked($Q11C[id]) <= 2 { message: Please do not select more than 2 attributes for [text]. } 1. Texture 2. Saltiness 3. Nutty flavor 4. Consistency 5. Aroma columns: 1. Skippy 2. Jif 3. Peter Pan 4. Planters 5. Store brand
Details
- Similar to regular validations, row and column validations consist of a condition and a
message
decorator. The condition is evaluated logical statement, and the message communicates to the respondent why they cannot proceed. - The validation is triggered when the condition evaluates to false.
- Validations can accept checked functions, list functions, Perl, regular expressions, and more, as input.
- Validations can be written in a single line, as shown above, or in multiple lines. The multi-line approach permits the use of here document (heredoc) syntax in the condition, allowing line breaks within the condition itself.
- Multiple validations may be added to a table.
- If your table has multiple columns, the validation tag must be added to the table root.
- Both the condition and the message can use option data placeholders such as
[id]
or[text]
.
Tip! To ensure a positive respondent experience, it's important to thoroughly test validations and write clear messages that explain what is needed for the respondent to proceed.
Additional examples
Multi-line validations
Row and column validations may also be written with a message tag on a separate line below the condition. Use the row validation condition
(alias rowval
) and row validation message
(alias rowmsg
) tags for this format.
row validation
10. Please select up to two attributes you feel most exemplify each brand. type: checkbox table row validation condition: countChecked($Q10R[id]) <= 2
row validation message: Please do not select more than 2 attributes for [text]. 1. Texture 2. Saltiness 3. Nutty flavor 4. Consistency 5. Aroma rows: 1. Skippy 2. Jif 3. Peter Pan 4. Planters 5. Store brand
column validation
Column validations work in a similar manner, and use the column validation condition
(alias colval
) and column validation message
(alias colmsg
) tags.
11. Please select up to two attributes you feel most exemplify each brand. type: checkbox table vscale: y column validation condition: countChecked($Q11C[id]) <= 2
column validation message: Please do not select more than 2 attributes for [text]. 1. Texture 2. Saltiness 3. Nutty flavor 4. Consistency 5. Aroma columns: 1. Skippy 2. Jif 3. Peter Pan 4. Planters 5. Store brand
Tip! The multi-line format allows for the use of heredoc so that complex conditions can be written on multiple lines, which helps with code readability.
For example:
row validation condition: <<END (anyChecked($Q15R[id],1) and $Q16R[id] >= 1 and $Q16R[id] <= 5) or (anyChecked($Q15R[id],2) and $Q16R[id] >= 6 and $Q16R[id] <= 10) or (anyChecked($Q15R[id],3) and $Q16R[id] >= 11) END
Applying multiple row validations
Multiple row validations can be applied to a table by listing each row validation
tag on a separate line, with no need for line breaks between the validations.
In this example, the first two validations ensure a text response is entered in the column that matches the selected radio option. The third and fourth validations ensure no text response is entered in columns that don't match the selected radio option.
set list: GROCERYSTORES 1. Trader Joes 2. Costco 3. Publix start table: 13 intro: For each store, indicate if you shop there. If you do, please specify the reason for shopping. If you don't, specify the reason you aren't a customer. row validation: !(anyChecked($Q13R[id]CA,1) and $Q13R[id]CB eq '') { message: For stores you DO shop at, please specify your reason in the "why" column. } row validation: !(anyChecked($Q13R[id]CA,2) and $Q13R[id]CC eq '') { message: For stores you DO NOT shop at, please specify your reason in the "why not" column. } row validation: !(anyChecked($Q13R[id]CA,1) and $Q13R[id]CC ne '') { message: For stores you DO shop at, please do not specify a reason in the "why not" column. } row validation: !(anyChecked($Q13R[id]CA,2) and $Q13R[id]CB ne '') { message: For stores you DO NOT shop at, please do not specify your reason in the "why" column. } rowsfrom: GROCERYSTORES -- column id: A type: radio 1. Do shop there 2. Never shop there required: y -- column id: B type: text size: 15 required: n heading: Why do you shop there? -- column id: C type: text size: 15 required: n heading: Why don't you shop there? end table
Adding validations to a multicolumn table
If your table has multiple columns, the validation tag must be added to the table root, above the first --
column separators.
In this example, respondents should assess a brand in column B only if they are at least slightly familiar with it in column A. Also, the message
decorator uses the [text]
placeholder to pull in option data. When a validation is triggered, the message will display the specific brand name from the BRANDS list.
set list: BRANDS 1. Skippy 2. Jif 3. Peter Pan 4. Planters 5. Store brand start table: 12 intro: For each brand you're familiar with, please rate your assessment on a scale of 1-5. rowsfrom: BRANDS row validation: !(anyChecked($Q12R[id]CA,2..5) and noneChecked($Q12R[id]CB,1..4)) { message: Please give an assessment of [text] since you are familiar with it. } -- column id: A type: radio heading: Awareness 1. Not at all familiar 2. Slightly familiar 3. Somewhat familiar 4. Very familiar 5. Extremely familiar -- column id: B enablewhen: anyChecked($Q12R__RID__CA,2..5) type: radio heading: Assessment required: n 1. Awful 2. Mediocre 3. Good 4. Exceptional end table
Note that because this is a multicolumn table, start table
/ end table
syntax is needed.
Implementing "if-else" statements
In the examples above, restrictions apply to all respondents, regardless of their answer selection. However, if you need a conditional validation statement, you can use an "if-else" statement. In the QPBRAND_SHARE example below, an "if-else" statement is used to ensure the validation applies only if the respondent checked and filled in "other specify" at QSFAVORITE_P. If this condition is true, either the row for this "other" must contain a value greater than 0%, or the respondent must have selected "I don't know" at QPBRAND_SHARE.
SFAVORITE_P. Which is your favorite piercing retailer?
type: radio
1. Brand 1
2. Brand 2
3. Brand 3
97. Other {autoother: y}
setlist: BRAND_SHARE_LIST
1. Brand 1
2. Brand 2
3. Brand 3
971. $QSFAVORITE_P_97_OTH {if anyChecked($QSFAVORITE_P,97)}
972. Other {autoother: y}
PBRAND_SHARE. Thinking about the <b>past 3 years</b>, what percent of your spend on piercings was with each of the following retailers?
class: add_to_100_percent
rowsfrom: BRAND_SHARE_LIST
dta: 98. I don't know
row validation: if (anyChecked($QSFAVORITE_P,97) and $QSFAVORITE_P_97_OTH ne '') {$QPBRAND_SHARER971>0 or anyChecked($TPBRAND_SHARE_DTA)} else {1} {message: You previously said you had purchased from $QSFAVORITE_P_97_OTH. Please ensure the value for this row is >0%.}
This example uses a system class for summing tables to 100%.
Version Notice: This article covers features in our r9/IS Pro platform. If you're looking for information on this topic related to r8, see Table row validation and column validation.
Comments
0 comments
Please sign in to leave a comment.