title: How to redirect to another page only after validating the input field in html
body: <p>I have a login page where the user enters the employee id .And upon entering I am trying validate and if certain condition is satisfied I will redirect to another page if not display an alert saying invalid input.</p>
  
  <p>1st page code:</p>
  
  <pre class="lang-js prettyprint-override"><code>function alphanumOnly(input) {
    var regex = /[^a-zA-Z0-9]/gi;
    input.value = input.value.replace(regex, "");
  }
  
  function getRepoCount() {
    alert(1);
    var empid = document.getElementById("ManagerId").value;
    alert(empid);
    $.ajax({
      url: 'http://localhost:8088/JirasTrackingApp/reporter/Reportees/ReporteeList/'+ empid,
      type: 'GET',
      contentType: "application/json; charset=utf-8",
      dataType: 'json',
      success: function(result) {
        var size = result.length;
        if (size &gt; 0) {
          window.location.href = "indextable.html";
          return true;
        } else {
          alert("Please enter an valid input");
          return false;
        }
      },
      /*error:function(result){
          return false;
          alert("Please enter an valid input");
      },*/
  
    });
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form action="indextable.html" method="GET"&gt;
    &lt;p&gt;&lt;input name="ManagerId" class="form-control" id="ManagerId" type="text" autocomplete="off" onkeyup="alphanumOnly(this)" maxlength="8" placeholder="ManagerId"&gt;&lt;/input&gt;
    &lt;/p&gt;
    &lt;p&gt; &lt;input type="button" onclick="return getRepoCount();" value="submit"&gt;Submit&lt;/body&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  
  
  <p>My 2nd html page:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;script&gt;
        const urlParams = new URLSearchParams(window.location.search);
        const myParam = urlParams.get('ManagerId');
        alert(myParam); //This displays null
        getReporteeList(myParam);
      &lt;/script&gt;
  </code></pre>
  
  <p>My index.js file which actually contains the getReportees()</p>
  
  <p>If I use the input type button and onclick function that will make an ajax call and validate. But if I give an valid input it should get redirected to 2nd html page, but after redirecting it displays the null in alert. So the input value is not being read in 2nd html page. But if I give invalid input it shows the alert message as invalid input in the first login page only.</p>