37

I have a log-in form that I want to validate and redirect (if the username and password are correct) with jQuery, and the redirect isn't working.

This is my code:

$(document).ready(function() {
    $('#lc-login').click(function() {
        var username = $('#username').val();
        var pass = $('#pass').val();        

        if (testUser(username) === true && testPass(pass) === true) {            
            window.location.replace("http://www.domain.com/home.html");
        } else {
            alert('warning message');
        }
    });
});

I've try replacing the window.location.replace with window.location.href and still nothing. I should say that the testUser and testPass are working fine, because if I add a simple alert('the validation is ok!'), the message is appearing on my screen.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Arron
  • 442
  • 1
  • 6
  • 10

0 Answers0