Prevent respondent from changing default answer | XM Community
Solved

Prevent respondent from changing default answer


Userlevel 1
Badge +6
  • Level 2 ●●
  • 16 replies

Respondents are presented with a single-answer multiple choice question with two possible responses and one response selected as the default choice.

My goal is to simply show respondents this set-up (default choice with two possible responses) but not allow them to change the selection away from the default.

Any help would be appreciated!

icon

Best answer by Deepak 16 May 2023, 22:47

View original

5 replies

Userlevel 5
Badge +22

Hello there! 

I’m sure someone will be able to provide you with a way to use code to not allow this, but one workaround you could leverage would be to use validation:

You can locate this by selecting your question and in Response Requirements adding custom validation with the criteria above. While it would allow the respondent to change their answer during the survey, they cannot continue to the next page of the survey (or finish the survey) until Option 1 is the one that remains selected. 

 

Userlevel 7
Badge +36

@Jon  You can add this onload in Javascript and change the number in eq below to the choice which has default option. Here 1 is second option.

jQuery('#'+this.questionId).find('input').eq(1).prop('disabled',true);

Hope it helps!

Userlevel 1
Badge +6

@Deepak thanks for your great reply.

@Jon  You can add this onload in Javascript and change the number in eq below to the choice which has default option. Here 1 is second option.

jQuery('#'+this.questionId).find('input').eq(1).prop('disabled',true);

Hope it helps!

 

As a follow-up to this, is it possible to also change the CSS styling of the non-default and default answers across multiple questions? For example, I tried something like this by inserting it into custom CSS under Look & Feel, but it applied the styling to the top and bottom response option, rather than to the default and non-default response option.

#question1 .ChoiceStructure li.Selection.alt label,
#question2 .ChoiceStructure li.Selection.alt label {
opacity: 0.6; /* Reduce the opacity of the non-default option */
}

/* Style the default option to make it more prominent */

#question1 .ChoiceStructure li.Selection.reg label,
#question2 .ChoiceStructure li.Selection.reg label {
font-weight: bold; /* Make the default option bold */
}
Userlevel 7
Badge +36

@Jon You can change the look and feel of each option via Rich Content Editor of that option. Or

If you would like to make the options bold you can just enable this option within look and feel for answer text.

And for the default option to make it that as normal and not bold you can use following:

jQuery('#'+this.questionId).find('label.MultipleAnswer.q-checked').css({"font-weight": "normal","opacity":"0.6"});

Hope it helps!

Userlevel 1
Badge +6

@Deepak Great, thank you again! I made a minor modification, which is to change MultipleAnswer to SingleAnswer, as this is a single answer multiple choice question. I also have a question: how would I use JS to change the CSS styling of the non-default option instead?

Leave a Reply