Have an idea?

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

Branching question


With the question "Branching" I have a problem and I will try to be as accurate as possible.

I have 2 questions on the same page, a simple question, 'yes' and 'no' and when I click 'yes' I have a multiple question that appears. If I click again 'no' I have an error telling me that I have to answer the hidden question.

In addition I don't understand the following comment:
Custom JavaScript verification can be used to make questions require a response only if shown. This code may help you get started: $('#[% QuestionName() %]_div').is(':visible')."

Thanks !
asked Feb 21 by Sylvain V
You need to turn off any require response functionality in the second question, then add it again with custom JavaScript verification.  The exact code depends on what type of question it is and what requirements you want for it.  Is this a checkbox select question?  What's the minimum and maximum checks you want to require?
Thanks Zachary ! Yes it's a checkbox select question with minimum 1 and maximum 5 checks.

1 Answer

0 votes
Start by removing the minimum and maximum checks inside your checkbox question's settings.  Then, set the checkbox question's custom JavaScript verification to this:

if (SSI_GetValue('SelectQ1') == 1) {
    var numChecked = 0;
    $('input[name=hid_list_[% QuestionName() %]]').val().split(',').forEach(function(i){
        numChecked += SSI_GetValue('[% QuestionName() %]_' + i);
    if (numChecked < 1 || numChecked > 5) {
        strErrorMessage = 'Error message.';

"SelectQ1" must be renamed to the name of the first select question.
answered Feb 21 by Zachary Platinum Sawtooth Software, Inc. (71,500 points)