Clear form after submission with jQuery
try this in your post methods callback function
$(':input','#myform')
.not(':button, :submit, :reset, :hidden')
.val('')
.removeAttr('checked')
.removeAttr('selected');
for more info read this
You can reset your form with:
$("#myform")[0].reset();
You can add this to the callback from $.post
$( '#newsletterform' ).each(function(){
this.reset();
});
You can't just call $( '#newsletterform' ).reset()
because .reset()
is a form object and not a jquery object, or something to that effect. You can read more about it here about half way down the page.
Better way to reset your form with jQuery is Simply trigger
a reset
event on your form.
$("#btn1").click(function () {
$("form").trigger("reset");
});