Jquery 如果验证失败,如何停止按钮的默认操作
我有一个多步骤表单,根据单击的按钮(Jquery 如果验证失败,如何停止按钮的默认操作,jquery,jquery-validate,Jquery,Jquery Validate,我有一个多步骤表单,根据单击的按钮(NEXT或BACK)隐藏/显示表单中的DIV元素 我还使用JQuery验证插件来验证表单 我只想在每次有人单击NEXT时验证表单。以下是我迄今为止的JQuery: $("#Next").bind("click", function(e) { $("#myForm").validate(); //validate the form when clicking on next $("#FormStepCurrent").hide();
NEXT
或BACK
)隐藏/显示表单中的DIV元素
我还使用JQuery验证插件来验证表单
我只想在每次有人单击NEXT
时验证表单。以下是我迄今为止的JQuery:
$("#Next").bind("click", function(e) {
$("#myForm").validate(); //validate the form when clicking on next
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show(); //show the new div
});
因此,当有人单击“下一步”按钮时,它会触发验证,然后应该显示下一个div。但是,如果当前可见div中存在验证错误,如何防止它隐藏/显示当前可见的div,直到错误得到纠正?您可以使用valid()
方法。它将运行完全验证并返回布尔值
$("#Next").bind("click", function (e) {
if (!$("#myForm").valid()) {
return;
}
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show(); //show the new div
});
您可以使用valid()
方法。它将运行完全验证并返回布尔值
$("#Next").bind("click", function (e) {
if (!$("#myForm").valid()) {
return;
}
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show(); //show the new div
});
您可以使用valid()
方法。它将运行完全验证并返回布尔值
$("#Next").bind("click", function (e) {
if (!$("#myForm").valid()) {
return;
}
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show(); //show the new div
});
您可以使用valid()
方法。它将运行完全验证并返回布尔值
$("#Next").bind("click", function (e) {
if (!$("#myForm").valid()) {
return;
}
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show(); //show the new div
});
试试这个:
$("#myForm").validate({
submitHandler: function(form) {
// do other things for a valid form
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show();
}
});
试试这个:
$("#myForm").validate({
submitHandler: function(form) {
// do other things for a valid form
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show();
}
});
试试这个:
$("#myForm").validate({
submitHandler: function(form) {
// do other things for a valid form
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show();
}
});
试试这个:
$("#myForm").validate({
submitHandler: function(form) {
// do other things for a valid form
$("#FormStepCurrent").hide(); //hide the current div
$("#FormStepNew").show();
}
});
在此处检查您的严重错误是否错误地认为
$(“#myForm”)。validate()
与//单击“下一步”时验证表单相同。.validate()
方法是插件的初始化方法,而不是验证测试方法。否则,您可以使用.valid()
方法在单击处理程序中验证表单。请检查此处,您的关键错误是错误地认为$(“#myForm”)。validate()
与//单击下一步时验证表单相同。.validate()
方法是插件的初始化方法,而不是验证测试方法。否则,您可以使用.valid()
方法在单击处理程序中验证表单。请检查此处,您的关键错误是错误地认为$(“#myForm”)。validate()
与//单击下一步时验证表单相同。.validate()
方法是插件的初始化方法,而不是验证测试方法。否则,您可以使用.valid()
方法在单击处理程序中验证表单。请检查此处,您的关键错误是错误地认为$(“#myForm”)。validate()
与//单击下一步时验证表单相同。.validate()
方法是插件的初始化方法,而不是验证测试方法。否则,您可以使用.valid()
方法在单击处理程序中验证表单。