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

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

  • 27 August 2018
  • 3 replies
  • 69 views

Userlevel 1
Badge +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".
icon

Best answer by TomG 27 August 2018, 22:42

View original

3 replies

Userlevel 7
Badge +20
try adding below code on "onReady" function.

jQuery("#NextButton").click(function(){

if(jQuery(".q-checked").length == 0)
{
alert("Please provide answer")
}
});
Userlevel 7
Badge +27
@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.
Userlevel 7
Badge +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