Browser warning when closing/refreshing except on Submit - Gravity form

Couldn’t really find an answer to this specific Gravity Forms question however I solved the issue using the below: It is based off code from another thread.

I use AJAX to submit the form however I have a page redirect on submit therefore needed the alert function to be removed on Submit. Any suggestions to improve the code would be great but defintely works for me.

var userStartedForm;
    jQuery(document).on('focus', '.gform_wrapper input', function(){
        userStartedForm = true;
	jQuery(window).on('beforeunload', function(){
        if(userStartedForm){ return ''; }
 var userSubmitedForm;
    jQuery(document).on('click', '#gform_submit_button_1', function(){
        userStartedForm = false;
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.