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

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?


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.