0

Just trying to get a very simple js login to validate a static username/password however cant seem to get it to work. Any help would be appreciated.

var checkLoginPass = function () {
    var login = document.getElementById("login").value;
    var pass = document.getElementById("password").value;
    if (login === "user123" && pass === "password1234") {
        window.location("http://www.google.com");
    }
    else {
        //do something else;
    }
};
<input type="text" id="login" required>
<input type="text" id="password" required>
<input type="button" id="goButton" onclick="checkLoginPass()" value="Log In"/>
Ry-
  • 218,210
  • 55
  • 464
  • 476
user1
  • 347
  • 2
  • 12
  • 22
  • 1
    `window.location` isn’t a function; I think you probably meant to set it. (And read the error message.) – Ry- Oct 24 '13 at 20:16
  • 3
    I hope you are aware that this offers **no security whatsoever**, since anyone can look at the source code and read the username and password. Or just go to the URL themselves to begin with. Just pointing it out... – deceze Oct 24 '13 at 20:18
  • @deceze yes. not a full implementing project, just testing purposes. – user1 Oct 24 '13 at 20:36

1 Answers1

0

Use location.replace("http://www.google.com"); instead of window.location("http://www.google.com");

NicolasMoise
  • 7,261
  • 10
  • 44
  • 65