title: e.preventDefault() is not working for submit button and anchor tag in MVC
body: <p>In my ASP.Net Core MVC App</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;form&gt;
  &lt;div class="container"&gt;
      &lt;div class="row"&gt;
          &lt;div class="col-md-offset-2 col-md-4"&gt;
              &lt;div class="form-group"&gt;
                  &lt;input type="text" class="form-control small" asp-for="UserName" /&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;input type="text" class="form-control small" asp-for="Password" /&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;a class="btn btn-sm btn-success pull-right" asp-action="Validate" asp-controller="LogIn" onclick="ValidateLogin()"&gt;Log In&lt;/a&gt;
                  &lt;input type="submit" value="LogIn" asp-action="Validate" asp-controller="LogIn" onclick="ValidateLogin(this)" /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>TypeScript Code</strong></p>
  
  <pre><code>   function ValidateLogin(e:Event) {
      var username = (document.getElementById('UserName') as HTMLInputElement).value;
      var password = (document.getElementById('UserName') as HTMLInputElement).value;
      if ((username.length &gt; 0) &amp;&amp; (password.length &gt; 0)) {
  
      }
      else {
          alert('Fields required');
          e.preventDefault();
      }
  }
  </code></pre>
  
  <p>If fields are empty than it should terminate the request , but it only display alert and e,preventDefault() is ineffective here . </p>
  
  <p>I also tried return false , but nothing seems to work here . It should not go to action  method after preventDefault or return false statement </p>
  
  <p>Can somebody tell me what am i missing here in this very simple task ?</p>
  
  <p><strong>Update 1</strong></p>
  
  <p>If i change the code in below way , than it works </p>
  
  <pre><code>document.getElementById('btn').onclick = function (e) {
  var username = (document.getElementById('UserName') as HTMLInputElement).value;
  var password = (document.getElementById('UserName') as HTMLInputElement).value;
  if ((username.length &gt; 0) &amp;&amp; (password.length &gt; 0)) {
  
  }
  else {
      alert('Fields required');
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Still i dont know why it is not working when i wrap it in a method instead of calling directly with .onclick()</p>