我有多种形式,其中包括许多输入字段和复选框。我必须验证所有这些内容,但是当我尝试验证两个以上输入字段时,下一个和上一个按钮将不起作用。如果我从jquery代码中删除以下代码,则下一个和prev按钮起作用。
else if($('#error2').val() === ""){
$("#error2").css("border", "1px solid red");
return false;}
jQuery代码
$(".next").click(function(){
//if(animating) return false;
animating = true;
current_fs = $(this).parent();
if($(this).parent().find('.form_radio_button_custom input:checked').val() == "Employee"){
$(".hd").addClass("active");
next_fs = $(this).parent().next().next();
}else if($(this).parent().find('.form_radio_button_custom input:checked').val() == "Other"){
$(".hd").addClass("active");
next_fs = $(this).parent().next().next();
}else if($('#red').val() === ""){
$("#red").css("border", "1px solid red");
return false;
}else if($('#error2').val() === ""){
$("#error2").css("border", "1px solid red");
return false;
}
else{
next_fs = $(this).parent().next();
}
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'transform': 'scale('+scale+')'});
next_fs.css({'left': left, 'opacity': opacity});
},
duration: 0,
complete: function(){
current_fs.hide();
//animating = false;
},
//this comes from the custom easing plugin
easing: 'easeOutQuint'
});
});
到此站点的链接没有代码link
else if($('#error2').val() === ""){
$("#error2").css("border", "1px solid red");
end;
}
现在我如何使代码在多个输入字段中工作。我在这里做错了。