JS to work on the same question on which it is written | XM Community
Skip to main content
Solved

JS to work on the same question on which it is written


Forum|alt.badge.img+4
I am wondering that how i can setup js on a question so that it should work on the same question on which it is written. I tried on Unload function, but it is not working. I have created a single punch grid as a non-mandatory grid, but I want that if anyone click on it without answering even a single response, he/she should see message "Please provide answer".

Best answer by TomG

@Mohammedali_Rajapakar_Ugam - That won't stop the page from advancing after the alert. @salimlko - Assuming your addOnUnload code was correct, change addOnUnload to addOnPageSubmit.
View original

3 replies

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
try adding below code on "onReady" function. jQuery("#NextButton").click(function(){ if(jQuery(".q-checked").length == 0) { alert("Please provide answer") } });

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • Answer
  • August 27, 2018
@Mohammedali_Rajapakar_Ugam - That won't stop the page from advancing after the alert. @salimlko - Assuming your addOnUnload code was correct, change addOnUnload to addOnPageSubmit.

MohammedAli_Rajapkar
QPN Level 5 ●●●●●
Forum|alt.badge.img+20
@TomG ... Good catch. However, I asked @salimlko to try it, if it doesn't work then we can look into it in more detail...

Leave a Reply