How does a button redirect to a page after having the email and password confirmed?

Asked

Viewed 25 times

-1

How to be directed to a next page after being confirmed the "email" and "password" in Javascript

<button onclick="b_login()" id="botaoLogin">LOGIN</button>

<script>
function b_login(){
  var email = login_email.value;
  var senha = login_senha.value;
  var email_passou = (email == '[email protected]')
  var senha_passou = (senha == '1234');
  if(email_passou && senha_passou){
    alert('Aguarde');
  }
  else{
    if(!email_passou){
       alert("Email invalido");
    }
    if(!senha_passou){
        alert("Senha invalida");
    }
  }
}
</script>

1 answer

1

Simulating a mouse click:

window.location.href = "http://www.google.com";

Simulating an HTTP redirect:

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

In your case, it would be something like this:

if(email_passou && senha_passou){
   window.location.replace("http://www.google.com");
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.