Possible Duplicate:
Blank out a form with jQuery
I am using a jQuery function to clear all my form values.
$.fn.clearForm = function() {
return this.each(function() {
var type = this.type, tag = this.tagName.toLowerCase();
if (tag == 'form')
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;
});
};
the problem with above function is it does not reset the file input field. is there anyway i could extend the function and make it to work with clearing file input field as well.
here is file input field HTML code i am using.
<section><label for="productimg">Picture<br></label>
<div><input type="file" id="productimg" name="productimg"></div>
</section>
thank you..