Thanks to all for your suggestions. I found a short and simple way on google which is more easy and convenient for this.
You can use input type selector for minimal code ie. $(':input') will select all text box field. If you want to clear all controls on current form I have written a small plugin you can use it:
$.fn.clearForm = function () {
return this.each(function () {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form' || tag == 'div')
return $(':input', this).clearForm();
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = '';
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
});
};
Usage:
$('#divId').clearForm();
$('.div_class').clearForm();
$('form').clearForm();
Source :
Click Here