Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Forcing a respondent to answer all columns in an "other specify" question

Hi,

I have a row-oriented grid question . The rows are select questions with a dropdown single response. One row is "other specify" and as such is not required, since I would like a respondent to be able to proceed without having to enter anything in the "other" row.

However, a respondent can choose 1 or 2 columns worth of dropdown responses in the "other" row without being forced to answer all 3. They have to type in the text box, but can leave columns blank and proceed.

How can I force a respondent who answers at least 1 column of the "other specify" row to be required to complete the entire row?
asked Nov 16, 2021 by Rick (310 points)

1 Answer

0 votes
 
Best answer
This may not be built-in, but we can achieve this by setting the row to not require a response and giving the grid question this custom verification:

// Parameters
var otherSpecifyRow = 4;
var errorMessage = 'Error...';

// Run
if (SSI_GetValue('[% QuestionName() %]_r' + otherSpecifyRow + '_other')) {
    $('input[name="hid_col_list_[% QuestionName() %]"]').val().split(',').forEach(function(column){
        if (!SSI_GetValue('[% QuestionName() %]_r' + otherSpecifyRow + '_c' + column)) {
            strErrorMessage = errorMessage;
        }
    });
}


Lines 2 and 3 should be updated to fit your needs.
answered Nov 16, 2021 by Zachary Platinum Sawtooth Software, Inc. (216,575 points)
selected Nov 18, 2021 by Rick
Excellent, this worked perfectly thank you! I have a few similar row-oriented grid questions but select questions with a radio button single response. The above verification forces me to answer the "other specify" row, but when I do I can't continue. It just brings up the error message.

How can I modify this to ensure that if a respondent enters text in the "other specify" text box they have to choose at least 1 column in the "other" row?
Try this:

// Parameters
var otherSpecifyRow = 4;
var errorMessage = 'Error...';

// Run
if (SSI_GetValue('[% QuestionName() %]_r' + otherSpecifyRow + '_other') && !SSI_GetValue('[% QuestionName() %]_r' + otherSpecifyRow)) {
    strErrorMessage = errorMessage;
}
Thank you!!! If I have more than one "otherSpecifyRow", how would I modify the verification? For example, if respondent types in either or both "other specify" row boxes but does not complete the columns?
The simplest solution would be to copy-and-paste that code for each row.  The two "var" would have to be removed from the later copies.
...