Only show pop up if validation is met? | XM Community
Skip to main content
Hi,



I would like to show participants a pop up if their answers to two questions are the same. I have found the code for a pop up (I have pasted this at the end of the question) which I have used but currently is shown to all participants.



Participants answer 2 allocation questions, in the second question the custom start position is their allocations from the first one. If they leave this unchanged, I would like to have a pop up as shown in the second screen shot. If they make changes, I do not want this pop up to appear.



!



!





Qualtrics.SurveyEngine.addOnReady(function()

{

const that=this;

this.hideNextButton();

var btn = jQuery('<div id="Buttons"><input id="CustomButton" class="NextButton Button" title=" Next " type="button" name="NextButton" value=" Next " aria-label="Next"></div>')

jQuery('#Buttons').append(btn);



jQuery('#CustomButton').on('click', function(){

var txt;

var e= jQuery("[id='QR~QID1']").val()

var r = confirm("Reminder: This is the allocation for bread products WITH a PGI, if you would like to change your allocation press cancel, if you do not want to change it press ok "+e); //design your question here

if (r == true) {

that.clickNextButton();

} else {



}



});



});



Thank you in advance!
hi @ChloeM ,



this.hideNextButton();

this.showNextButton();



above code can be used to show/hide the Next Button.



For further javascript reference you can use this link
@ChloeM,



Inside your click handler, you need to compare the answers of the two questions, then only execute the confirm if they are the same.

Leave a Reply