следующая и ценная кнопка не работает после проверки более чем одной проверки - PullRequest
0 голосов
/ 16 октября 2018

У меня есть несколько форм, которые включают много полей ввода и флажок. Я должен проверить все из них, но когда я пытаюсь проверить больше чем два поля ввода, следующая и предыдущая кнопка не работает.Если я удаляю приведенный ниже код из кода jquery, то следующая и предыдущая кнопка работает.

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'
    });
});

ссылка на сайт здесь без кода ссылка

else if($('#error2').val() === ""){
    $("#error2").css("border", "1px solid red");
    end;
}

Теперь, как мне заставить код работать с несколькими полями ввода. Что я здесь делаю не так.

...