In the jquery steps, When a user clicks next, I want to make sure all the blanks required are filled, otherwise, an alert will popup. For example, in one steps, there are 6 checkboxes and the user needs to choose at least one, how to add the event listener to next button?
Asked
Active
Viewed 4,404 times
2
-
2Please add your code to the question. – Clinton Green Jan 16 '17 at 22:43
1 Answers
1
Please look at Events section here. There is onStepChanging
event.
So you can add the event listener like this:
$("#example").steps({
// options
// ...
onStepChanging: function (event, currentIndex, newIndex) {
if (!validate()) {
// alert and stop when some validation failed
alert("Error");
return false;
} else {
// proceed
return true;
}
}
});

Yurii Semeniuk
- 933
- 8
- 13
-
1Great! As an addition: If you want to handle only clicks on the next button, you could check `if (newIndex > currentIndex) { // do something }` inside the `onStepChanging` function. – Tim Kohlen Jun 24 '19 at 14:56