jQuery : How to do validation in jquery before submit the form?
<p>I have a form bootstrap form like below</p>

<pre><code>&lt;form id="loginForm" method="post" action="" role="form" class="ajax"&gt;
   &lt;div class="form-group"&gt;
       &lt;label for="userName"&gt;&lt;/label&gt;
       &lt;input type="text" class="form-control" id="usrName"&gt;
    &lt;/div&gt;

   &lt;div class="form-group"&gt;
       &lt;label for="passWrd"&gt;&lt;/label&gt;
       &lt;input type="password" class="form-control" id="passWrd"&gt;
    &lt;/div&gt;

   &lt;div class="form-group"&gt;
       &lt;button class="btn btn-default" type="button" id="loginButton"&gt;Login&lt;/button&gt;      
    &lt;/div&gt;
</code></pre>

<p>I am doing form validation in my jquery as below. How do I call <code>submit()</code> method  in my code? i.e how do I make ajax call to submit the form content after validation in the jQuery.</p>

<pre><code>$(document).ready(function() {

  function validateInput(id) {
    if($("#"+id).val()==null || $("#"+id).val()=="") {
      var div=$("#"+id).closest("div");
      div.addClass("has-error");
      return false;
    } else {
      var div=$("#"+id).closest("div");
      div.removeClass("has-error");
      div.addClass("has-success");
      return false;
    }     
  }
  $(#loginButton).click(function() {
enter code here
    if(!validateInput("userName"))
    {
      return false;
    }

    if(!validateInput("passWrd"))
    {
      return false;
    }

  });

});
</code></pre>

<p>How do i call $.ajax after i complete the validation in my above code?</p>

<p>P.S : I am not supposed to use any jquery plugin for the validation.</p>