Hi, I couldn't find any docs on this, or any GF function to perform some kind of a reset. I'm using the twitter bootstrap js modal (I had issues with js conflict when using others...). the modal js has a callback function run when the modal is closed.
So, this bit of jQuery seems to do the trick:
// reset the contact form on modal close
jQuery('#myModalWindow').on('hide', function () {
$this = $(this);
$this.find('form')[0].reset();
$this.find('.val_summary').remove(); // the validation summary message
$this.find('input[type=text]').val(''); // this appears to be necessary because if a field passes validation and then I reset the form, these fields do not reset for some reason.
$this.find('li.gfield_error div.validation_message').remove(); // remove the validation meesages
$this.find('li.gfield_error').removeClass('gfield_error'); // remove the validation classes.
});
Posted 12 years ago on Tuesday June 19, 2012 |
Permalink