Reset form with jQuery (part II)

Here I noted how to reset a form with jQuery, however, later I noticed some fields aren’t reset() correctly: in my form I have hidden fields with initial value of “0″ (or just an empty value) and these fields are supposed to be changed interactively upon a user’s input using jQuery. These fields weren’t reset correctly for some reason, at least in Firefox, thus I had to change my original function to something like this:

function resetForm(id) {
	$('#' + id + ' :input').each(function(){  // I decided not to have different reset routine for different field types

Probably less elegant, but works… ;)

This entry was posted on Saturday, November 29th, 2008 at 03:05 and is filed under jQuery. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “Reset form with jQuery (part II)”

Testing yaCAPTCHA.

How about: $(“#form_id”)[0].reset();

Works on my side ;)


Yes, I tried to describe this way here, however I had problems with reseting hidden fields which had values changed dynamically by jQuery upon a user interaction :-/


Leave a Reply


required (will not be published)