JQuery – Clearing hidden fields
JQuery’s form plugin provides several convenient methods for clearing/resetting form element values. However, the clearForm method does not reset hidden fields. Here is a simple implementation for clearing hidden fields:
jQuery.fn.clearHiddenFields = function() { return this.each(function(){ $("input[type='hidden']", this).each(function(){ this.value = ''; }); }); };
Invoking this method is very straightforward:
$("#yourformid").clearHiddenFields();
or simply:
$("form").clearHiddenFields();