Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Redirect after logging in (if/else statement)

My window.location.replace is not working, by which I mean it's not redirecting. Please help.

My website:

enter image description here

function validate(){
    var username=document.getElementById('login-username').value;
    var passowrd=document.getElementById('login-password').value;

    if (username === "daksh" && passowrd === 'daksh'){
        alert('You have sucessfully logged in');
        window.location.replace("http://stackoverflow.com");
    } else{
        alert('Wrong username or password');
        return true;
    }
}
<div action="login.html" class="container">
 <form  method="POST" class="login-form">
    <h1 class="login-heading">LOGIN FORM</h1>
     <input type="text" placeholder="User Name" id="login-username">
     <br><br>
     <input type="password" placeholder="Password" id="login-password">
     <br><br><br>
     <input type="submit" value="Login" id="login-submit" onclick="validate()">
 </form>
</div>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!