Matrix Likert Answers Count Validation across multiple questions | XM Community
Skip to main content

I have a 5 Matrix Likert Multiple Answers questions on one page. I’d like respondents to click on at least 8 points in total across the 5 questions before they proceed.

 

I did find some JS in another post that counts the answers on one question (and that disables the next button until they click enough answers), but not sure how to adjust that to check across the 5 questions…

Qualtrics.SurveyEngine.addOnReady(function(){
that = this;
var init_ques = this.getQuestionTextContainer().innerText;
this.disableNextButton();
this.questionclick = function () {
var a = that.getSelectedAnswers();
var ch = Object.values(a).reduce(function (a, b) {
return a + b;
},0);
if(ch >=3){
that.enableNextButton();
that.getQuestionTextContainer().innerText = "Okay to proceed";
} else {
that.disableNextButton();
that.getQuestionTextContainer().innerText = init_ques;
}
}
});

 

Use the below code in any one of the Matrix question

Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.disableNextButton();
jQuery(".Matrix").find("input[type='checkbox']").on('change',function(){
if(jQuery(".Matrix").find("input[type='checkbox']:checked").length>=8)
that.enableNextButton();
else
that.disableNextButton();
});
});

 


Use the below code in any one of the Matrix question

Qualtrics.SurveyEngine.addOnReady(function() {
var that = this;
this.disableNextButton();
jQuery(".Matrix").find("input[type='checkbox']").on('change',function(){
if(jQuery(".Matrix").find("input[type='checkbox']:checked").length>=8)
that.enableNextButton();
else
that.disableNextButton();
});
});

 

Perfect. Thank you!


Leave a Reply