Given a Group and Rank question, is it possible to add a popup/window that:
(1) Pops when the user presses the Next button & there aren't exactly 2 answers in the column.
(2) Asks "Are you sure you would like to continue?", the button Yes will continue to the next question, the button No will return to the same question.
(*) Clarification: I DO NOT want to FORCE an answer, only to check validation.
Thanks in advance.
Solved
Costume Conditional Proceeding for Pick, Group and Rank Questions
Best answer by AnthonyR
Try something like this!
Preview
Note you will need to use CSS to style CustomButton to match your themes NextButton.
Qualtrics.SurveyEngine.addOnReady(function()
{
const numberPerGroup = 2;
const errorMessage = 'Not every group has 2 elements, are you sure you want to continue?';
const that = this;
this.hideNextButton();
var btn = jQuery('<input id="CustomButton" class="NextButton Button" title=" >> " type="button" name="NextButton" value=" >> " aria-label="Next">')
jQuery('#Buttons').append(btn);
jQuery('#CustomButton').on('click', function(){
let passing = true
const groups = jQuery('.Group').map(function(){
return jQuery(this).find('ul');
}).map(function(){
return jQuery(this).map(function(){
return jQuery(this).find('li')
})
});
groups.each(function(){
if(jQuery(this)[0].length !== numberPerGroup){
passing = false
}
});
if(!passing){
let cont = confirm(errorMessage);
if(cont){
that.clickNextButton();
}
}else{
that.clickNextButton();
}
});
});
View originalPreview
Note you will need to use CSS to style CustomButton to match your themes NextButton.
Qualtrics.SurveyEngine.addOnReady(function()
{
const numberPerGroup = 2;
const errorMessage = 'Not every group has 2 elements, are you sure you want to continue?';
const that = this;
this.hideNextButton();
var btn = jQuery('<input id="CustomButton" class="NextButton Button" title=" >> " type="button" name="NextButton" value=" >> " aria-label="Next">')
jQuery('#Buttons').append(btn);
jQuery('#CustomButton').on('click', function(){
let passing = true
const groups = jQuery('.Group').map(function(){
return jQuery(this).find('ul');
}).map(function(){
return jQuery(this).map(function(){
return jQuery(this).find('li')
})
});
groups.each(function(){
if(jQuery(this)[0].length !== numberPerGroup){
passing = false
}
});
if(!passing){
let cont = confirm(errorMessage);
if(cont){
that.clickNextButton();
}
}else{
that.clickNextButton();
}
});
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.