title: Issue redirecting to a new page in Javascript
body: <p>I am new to JavaScript and am trying to compare two input fields before going to another page.  The goals is that when a button is clicked the text from two input fields is compared and then the page is redirected to another page.  I have tried using <code>window.location.href</code> as well as <code>window.location.replace</code> but so far nothing has worked.  The redirect should be executed because the alert in the same block of logic is being executed.  Thank you for any help.</p>
  
  <pre><code>&lt;html&gt;
  
      &lt;head&gt;
          &lt;script type="text/javascript"&gt;
              function sub(){
                  if(document.getElementById("p1").value == document.getElementById("p2").value){
                      alert("success");
                      window.location.replace="http://localhost:8080/newUser.php";
                  } else {
                      alert("Password do not match");
                  }
              }
          &lt;/script&gt;
      &lt;/head&gt;
  
  &lt;body&gt;
      &lt;form onSubmit="sub()" method="post"&gt;
          Password: &lt;input type="text" id="p1" name="password"&gt;&lt;br&gt;
          Confirm Password: &lt;input type="text" id="p2" name="passwordConfirm"&gt;&lt;br&gt;
          &lt;input type="submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>