Only show pop up if validation is met? | XM Community
Solved

Only show pop up if validation is met?

  • 16 January 2019
  • 2 replies
  • 19 views

Badge
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!
icon

Best answer by PraDeepKotian_Ugam 16 January 2019, 13:32

View original

2 replies

Userlevel 6
Badge +21
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
Userlevel 7
Badge +27
@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