Have an idea?

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

Grid question: force response for at least one column per row

Hi all,

i am using a grid question with numeric input, 5 rows and 3 columns. I want every respondent to fill out at least one column per row.

However, I am only able to specify "require response" in the row overview, which would require the respondent to fill out all columns.

Is there away to require at least one input per column?

Thanks!
asked Apr 11, 2017 by Philipp

1 Answer

+2 votes
Here's the custom JavaScript verification you need:

var rows = $('input[name=hid_row_list_[% QuestionName() %]]').val().split(',').map(Number);
var cols = $('input[name=hid_col_list_[% QuestionName() %]]').val().split(',').map(Number);

rows.forEach(function(row){
    var answered = false;
    cols.forEach(function(col){
        if ($('#[% QuestionName() %]_r' + row + '_c' + col).val().length) {
            answered = true;
        }
    });
    if (!answered) {
        strErrorMessage = 'ERROR';
    }
});
answered Apr 11, 2017 by Zachary Platinum Sawtooth Software, Inc. (78,750 points)
That worked like a charm, thanks a lot Zachary!
...