您可以在单击下一步时检查表格是否有效。
$(document).ready(function() {
$('#smartwizard').smartWizard({
onLeaveStep:leaveAStepCallback,
onFinish:onFinishCallback
});
$("form").validate({
rules: {
'student[business_representative_attributes][first_name]': 'required'
},
messages: {
'student[business_representative_attributes][first_name]': 'Please enter first name'
}
});
});
function leaveAStepCallback(obj, context){
alert("Leaving step " + context.fromStep + " to go to step " + context.toStep);
// return false to stay on step and true to continue navigation
if ($('form').valid()) {
return true;
} else {
return false;
}
}
智能精灵 4
$("#smartwizard").on("leaveStep", function(e, anchorObject, stepNumber, stepDirection) {
return confirm("Do you want to leave the step "+stepNumber+"?");
});