Chrome Back Button Cache Problem

Hey there… I’m doing an inline gravity form. All works well except when someone uses the back button only on the chrome browser. On Firefox or Safari, the form resets when the back button is used, but on chrome it does not. I tried a hook to force it to reset, but nothing is working. Any thoughts??

What hook did you use to reset the form field on the browser back button?

Also, do you have a link to the page with the form so we can take a look? Thank you.

Thanks Chris!

https://www.duraclutch.com, the form on the top of the page for " WHICH DURACLUTCH KIT FITS YOUR VEHICLE?"

This is what I tried, or a bunch of versions of it:

Hi Larry. From what I read online (Stack Overflow :joy:) it appears that what you are trying in that screenshot should work. However, when I visit your page, I get a JavaScript error:

TypeError: $ is not a function

That happens a lot in WordPress when you use $ rather than jQuery. Try updating your script like this:

<script>
  jQuery(window).load(function() {
    jQuery('gform_4').get(0).reset();
  });
</script>

That should get rid of the TypeError: $ is not a function error, and may work, or may show another error :slight_smile:

Thank you Chris!

Jquery is not my strength… I think this just changed the error to "get is undefinded? Agree?

Screen Shot 2020-03-31 at 3.32.39 PM

To be honest, mine either. I was just looking at probably the same Stack Overflow page you were. https://stackoverflow.com/a/27544317/811418

At least the $ is not defined error is gone. That was preventing the script from working at all. Now that that is resolved, we just need to find a method that works for your form :wink:

I will keep looking…

I will look as well if that is supposed to work.

I wasn’t able to get the reset functions from the API or the above mentioned to work. But I solved this with some classic js:

(function($) {
    $(window).load(function() {
        if($('#gform_18')) { //change to the ID of your form
            $("form").each(function(){
                $(this).find(':input').val('');
                $(this).find('.gfield_error').removeClass('gfield_error');
                $(this).find('.validation_message').remove();
            });
        }
    });
}(jQuery));