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:
1 2 3 4 5 | function resetForm(id) { $('#' + id + ' :input').each(function(){ // I decided not to have different reset routine for different field types $(this).val(''); }); } |
Probably less elegant, but works… ![]()
Testing yaCAPTCHA.
How about: $(”#form_id”)[0].reset();
Works on my side
Koen,
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 :-/