PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Reset form after Confirmation

  1. Hi,

    I've got a form working in a modal window. The form sends and displays the confirmation. However if a user closes the modal then clicks to send another message the modal opens and displays the same confirmation. How do I get the form to reset once a message is sent.

    Cheers

    Posted 12 years ago on Friday April 20, 2012 | Permalink
  2. Do you have a link to share by chance?

    Posted 12 years ago on Friday April 20, 2012 | Permalink
  3. 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 11 years ago on Tuesday June 19, 2012 | Permalink