lundi 11 juillet 2016

jQuery run through multiple if statements then continue


just doing a little little sign up page, and im trying to make it check each field if it has a value if not it will add the class of .error but if all 3 inputs have a value then display the success page

$(".btn").click(function() {
    //Check to see if the inputs have any data
    if ($('.username-input').val() == '') {
        $(this).addClass('error');
    }
    else if ($('.password-input').val() == '') {
        $(this).addClass('error');
    }
    else if ($('.email-input').val() == '') {
        $(this).addClass('error');
    }

    //if all inputs have data open up success page and close it.
    $(".btn").click(function() {
        $(".success-wrapper").animate({
            bottom: "0%"
        }, 'slow');
    });
    $(".close").click(function() {
        $(".success-wrapper").animate({
            bottom: "-100%"
        }, 'slow');
    })
});;

Aucun commentaire:

Enregistrer un commentaire