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?
Any reason this shouldn't be used?
For jQuery 1.6+:
For jQuery < 1.6:
Please see this post: Resetting a multi-stage form with jQuery
Or
As jQuery suggests:
If you want to empty all input boxes irrespective of its type then it's a minute step by
Use this Code Where you want to Call Normal Reset Function by jQuery
And Write this Function Out Site jQuery on Document Ready
frmID
is the identification of the formOnSuccess
of the operation we call the JavaScript function with the name "ClearInput
"if you do both of these right, then you will not be able to stop it from working...
Let us say if you want to clear the fields and except accountType,in the mean time dropdown box will be reset to particular value,i.e 'All'.Remaining fields should be reset to empty i.e text box.This approach will be used for clearing particular fields as our requirement.