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?
The following code clear all the form and it's fields will be empty. If you want to clear only a particular form if the page is having more than one form, please mention the id or class of the form
where
editPOIForm
is theid
attribute of your form.Why does it need to be done with any JavaScript at all?
http://www.w3.org/TR/html5/the-input-element.html#attr-input-type-keywords
Here's a way to do it with jQuery, then:
Add hidden reset button as follows
Why you dont use
document.getElementById("myId").reset();
? this is the simple and pretty