Validating a question on "next" button click | XM Community
Skip to main content
Question

Validating a question on "next" button click

  • March 4, 2021
  • 2 replies
  • 91 views

I have some custom validation that I want to execute when the next button is clicked. If the validation passes, I want to go on to the next question, if the validation fails I want to display an error and prevent the "next" action.
I tried
jQuery.on("click keydown submit", function(){
var goodToGo = myvalidation();
return goodToGo;
});

Returning false if to prevent event bubbling, but this did not work.
Other suggestions?


2 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • March 4, 2021

There are too many event listeners attached to the next button. I suggest creating a fake next button and using that for validation. If it passes, you could just send the click event to the next button.


  • Author
  • March 4, 2021

good idea... what I ended up doing was disabling the next button thru the api, attaching my event handlers and if passes validation reenable the next button and then fire it thru the api.