$.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form') {
$('td.status', this).empty();
return $(':input', this).clearForm();
}
if (type == 'text' || type == 'password' || tag == 'textarea' || tag ==
'label')
this.value = '';
else if (type == 'checkbox' )
this.checked = false;
else if (tag == 'select')
this.selectedIndex = -1;
});
};and just call this as,
function clearaddform() {
$("#aspnetForm").clearForm();
}and now you can just call clearaddform function from your button.