how can i disable Submit Button if answer is "No" | XM Community
Skip to main content
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
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.
If they hit no they should go back and answer unanswered questions
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;

}

});
```

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

});

```
thank you Tom, Shubham, @jpardicusick.

I will try out these options and let you know if it worked

Leave a Reply