title: Reset a form with Jquery
body: <p>I'm trying to reset a form with Jquery in a web application I'am developing with Java and Tapestry. The problem is that Tapestry doesn't provide any kind of method to reset a form, so I need to create a JS module for it.</p>
  
  <p>I have about 4-5 forms in my application with different id's, so I tried this:</p>
  
  <pre><code>define(["jquery"], function($) {
  
      return function() {
          $("form").on("submit", function() {
              if (!$("form-group").hasClass("has-errors") &amp;&amp; !$("div").hasClass("alert")){
                  $("form").reset();
              }
          });
      }
  
  })
  </code></pre>
  
  <p>This is my first time with JQuery, so it doesn't works. What I'm trying to do is set a callback when the submit button of the form gets hitted.
  This is my button declaration inside the form:</p>
  
  <pre><code>&lt;div class="col-md-offset-5 col-md-3"&gt;&lt;button class="btn btn-block btn-primary" type="submit"&gt;&lt;span class="glyphicon glyphicon-plus"&gt;&lt;/span&gt; Add
  </code></pre>
  
  <p></p>
  
  <p>I have only one form on each page. I think this is quite simple, but i can't get it to work. Anyone can give me some help with this? Thanks.</p>