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.
<script>
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;
});
</script>