mardi 5 mai 2015

Jquery if/else redirect showing the "else" value when an "if" is true

I have a jquery if/else written that checks the value of a textbox and if is equal to a word(s) it will redirect to a url - else it changes the value of the textbox to "try again". What is happening is when the if value is true and the redirect happens, I can see the else value pop up quickly in the textbox before the redirect happens.

Here is what I have:

$(document).ready(function() {
    $('#passphrase').focus();
    $('#passphrase').keyup(function(e) {

        if (e.which === 13) {

            if ($('#passphrase').val() == "marina heights") {
                window.location = "marina heights/index.html";
            }

            else {
                $('#passphrase').val("try again");
            }
        }
    });
});

Thank you in advance for any help!

Aucun commentaire:

Enregistrer un commentaire