-5

I am trying to figure out how to send a user to another page I design after they have input the correct password. I don't know how to load the page with a JavaScript Command. How could i use the code below to open a new page titled insideVault.html?

I have tried many google searches, but cant find any resources to help me out with this.

// login code //
   <div class = "container">
        <div class = "passwordEnter">
          <div class = "text-center">
            <form id="login" onsubmit="return passCheck()" method="get">
            <p> Enter Password </p>
            <input type="password" name="password" id = "password">
            <input type="submit">
            </form>
          </div>
        </div>
      </div>
    <script src="script.js"></script>
    </div>
    <script>
      function passCheck(){

  var input = document.getElementById("password").value == 'test';  
  console.log(input);
  if(!input){
        alert('Password incorrect, please try again.');
        return false;
    }

    return true;
}

I want the code to load a new page, but so far I have not been able to find any code that would allow me to do this.

1 Answers1

0

Try location.href:

function passCheck(){

  var input = document.getElementById("password").value == 'test';  
  console.log(input);
  if(!input){
        alert('Password incorrect, please try again.');
        return false;
    }
  location.href = 'insideVault.html';
}
glinda93
  • 7,659
  • 5
  • 40
  • 78