I want to clear all input and textarea fields in a form. It works like the following when using an input button with the reset
class:
$(".reset").bind("click", function() {
$("input[type=text], textarea").val("");
});
This will clear all fields on the page, not just the ones from the form. How would my selector look like for just the form the actual reset button lives in?
I've written a universal jQuery plugin:
This won't handle cases where form input fields have non empty default values.
Something like should work
I use this :
And here is my button:
Most easy and best solution is-
$("#form")[0].reset();
Don't use here -
$(this)[0].reset();
$('form').submit(function() {
});