Have an idea?

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

Requiring minimum of 1 in each constant sum box if "Not Applicable" is NOT selected.

Is there a way to use this question as stated AND still require a minimum response of 1 in each constant sum option box if "Not Applicable" box is not selected? I assume this will take some custom Java, which I would really appreciate help with.
asked Mar 22, 2021 by Makella

1 Answer

0 votes
Try setting your constant sum to use this custom JavaScript verification:

var notApplicableQuestion = $('#[% QuestionName() %]_div').nextAll('.select').attr('id').replace(/_div$/, '');
var notApplicable = false;
$('input[name="hid_list_' + notApplicableQuestion + '"]').val().split(',').forEach(function(item){
    if (SSI_GetValue(notApplicableQuestion + '_' + item)) {
        notApplicable = true;
    }
});
if (!notApplicable) {
    $('input[name="hid_list_[% QuestionName() %]"]').val().split(',').forEach(function(item){
        if (!SSI_GetValue('[% QuestionName() %]_' + item)) {
            strErrorMessage = 'my error message...';
        }
    });
}
answered Mar 23, 2021 by Zachary Platinum Sawtooth Software, Inc. (205,575 points)
...