how can i disable Submit Button if answer is "No" | XM Community
Solved

how can i disable Submit Button if answer is "No"

  • 29 May 2019
  • 5 replies
  • 212 views

Userlevel 2
Badge +1
Looking for guidance to disable Submit Button if answer is "No" in single select select question with Yes/No choices.

Example:
Are you sure you want to submit the survey?
1. Yes
2. 2. No

If answer is yes then submit button is enables and if answer is No then submit button is disabled
icon

Best answer by jainshubham 29 May 2019, 16:49

View original

5 replies

Userlevel 7
Badge +11
What should happen if they hit no?

I would use branching logic to either send them to the end of the survey (if yes) or send them back to wherever they should go if no.
Userlevel 2
Badge +1
If they hit no they should go back and answer unanswered questions
Userlevel 3
Badge +3
Hi @Rahul,

If you want to accomplish this feat using JS, below is the code you can use. You would need to replace the button ID (NextButton) & option ID's (QID1-1-label, QID1-2-label) with your survey's relevant id's that you can find by inspecting the elements.

Qualtrics.SurveyEngine.addOnReady(function()
{
document.getElementById('QID1-1-label').onclick = function(){
document.getElementById("NextButton").disabled = false;
}
document.getElementById('QID1-2-label').onclick = function(){
document.getElementById("NextButton").disabled = true;
}
});
Userlevel 7
Badge +27
```
Qualtrics.SurveyEngine.addOnload(function() {
var qobj = this;
jQuery("#"+this.questionId+" input[type=radio]:first").click(function() { qobj.enableNextButton(); }); //Yes
jQuery("#"+this.questionId+" input[type=radio]:last").click(function() { qobj.disableNextButton(); }); //No
});
```
Userlevel 2
Badge +1
thank you Tom, Shubham, @jpardicusick.
I will try out these options and let you know if it worked

Leave a Reply