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.
I have about 4-5 forms in my application with different id's, so I tried this:
define(["jquery"], function($) { return function() { $("form").on("submit", function() { if (!$("form-group").hasClass("has-errors") && !$("div").hasClass("alert")){ $("form").reset(); } }); } }) 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:
<div class="col-md-offset-5 col-md-3"><button class="btn btn-block btn-primary" type="submit"><span class="glyphicon glyphicon-plus"></span> Add 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.