未经测试,但你不能这样做:
$('#tabs').find(":input").each(function ()
{
if (!validator.element(this)) { // validate every input element inside this step
anyError = true;
// trigger click on the tab that is linked to $(this).parents('yourtabcontainername') here
return false; // ends each
}
});
if (anyError)
return false; // exit if any error found
//save ...
或者,如果您希望检查所有输入,无论您可以执行以下操作:
var validator = $("form").validate(); // obtain validator
var anyError = false;
var firstError;
$('#tabs').find(":input").each(function ()
{
if (!validator.element(this)) { // validate every input element inside this step
anyError = true;
if(firstError === undefined){
//set firstError to reference the tab that is linked to $(this).parents('yourtabcontainername')
}
}
});
if (anyError) {
//trigger click on firstError
return false; // exit if any error found
}
//save ...
这些中的任何一个都与您正在寻找的东西有关吗?