Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

437
Vistas
Trying to redirect page after login validation using javascript and html, won't work

So just starting coding in html and js, need some help as to why the page isn't redirecting after validation. The page just resets after logging in, and i'm trying to get it to redirect to login.html. Any help please?

DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Task Manager</title>
    <link rel="stylesheet" href="style.css">
    <script src ="login.js"> </script>
  </head>
  <body>
    <div class="center">
      <h1>Task Manager</h1>
      <form method="post">
        <div  class="txt_field">
          <input type="text" required name="" id="username">
          <span></span>
          <label>Username</label>
        </div>
        <div class="txt_field">
          <input type="password" name=""  id="password">
          <span></span>
          <label>Password</label>
        </div>
        <div class="pass">Forgot Password?</div>
        <input type="submit" name="" value="Login"  onclick="validate()">
        <div class="signup_link">
          Not a member? <a href="#">Signup</a>
        </div>
      </form>
    </div>

  </body>
</html>

Javascript:

function validate()
{
var username=document.getElementById("username").value;
var password=document.getElementById("password").value;
if(username=="admin"&& password=="user")

{

    alert("login succesfully");
    window.location.href = "./todo.html";

    return false;
    
}
else
{
    alert("login failed");
    return false;


}

}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your problem is in the java script in the return part so I don't remember exactly how to end the redirect in true

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can change window.location.href = "./todo.html"; to window.location = "./todo.html";

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda