Validating a question on "next" button click | XM Community
Question

Validating a question on "next" button click

  • 4 March 2021
  • 2 replies
  • 44 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

Userlevel 7
Badge +21

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.

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.

Leave a Reply