<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Javascript alert when leaving multiple page form</title>
		<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form</link>
		<description>Gravity Support Forums Topic: Javascript alert when leaving multiple page form</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 10:03:47 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/javascript-alert-when-leaving-multiple-page-form" rel="self" type="application/rss+xml" />

		<item>
			<title>greg on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-48723</link>
			<pubDate>Wed, 08 Feb 2012 14:04:35 +0000</pubDate>
			<dc:creator>greg</dc:creator>
			<guid isPermaLink="false">48723@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I want to follow up again on this conversation, because I never got a response to my last two posts.  &#60;/p&#62;
&#60;p&#62;Is this an issue you can provide support on?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>greg on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-45448</link>
			<pubDate>Wed, 04 Jan 2012 15:12:26 +0000</pubDate>
			<dc:creator>greg</dc:creator>
			<guid isPermaLink="false">45448@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;It's been a couple of weeks since my last post.  I realize everyone was busy over the holiday season, but I'm curious if you guys have any additional information on resolving this issue.  Any ideas, help, or advice would be appreciated.&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>greg on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-44263</link>
			<pubDate>Fri, 16 Dec 2011 17:07:39 +0000</pubDate>
			<dc:creator>greg</dc:creator>
			<guid isPermaLink="false">44263@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for your help, Chris.  I've added the code from your last forum post into a Wordpress page containing a test form, which is a single page.  The script generates the following alert message when I use Safari:&#60;/p&#62;
&#60;p&#62;&#34;Are you sure you want to reload this page? You have entered text on this form.  If you reload the page, your changes will be lost.  Do you want to reload the page anyway?&#34;&#60;br /&#62;
The alert has options to either cancel or reload.&#60;/p&#62;
&#60;p&#62;That's exactly what I was hoping for.  But in Safari, the alert message is only being displayed some of the time.  I've played around with the test form quite a bit, and most of the time the alert will be displayed if two or more fields are filled in.  But some times it won't display the alert when it should.  &#60;/p&#62;
&#60;p&#62;I looked at the error console in the Safari web inspector, and it's displaying two errors:&#60;/p&#62;
&#60;p&#62;ReferenceError:  Can't find variable: jQuery&#60;br /&#62;
Failed to load resource:  Could not connect to the server. &#60;/p&#62;
&#60;p&#62;The script you posted isn't working at all in Firefox or Opera on OSX.  I can reload the page or close the tab without any alert message being displayed at all, even if all of the questions on the test form are filled out.  I've also loaded the test form in Windows XP, using Firefox and IE8, and wasn't able to get the alert message to display in those browsers.&#60;/p&#62;
&#60;p&#62;The error console for Opera displays one error (which appears to be the same error as is being displayed in Safari's console):&#60;/p&#62;
&#60;p&#62;Uncaught exception: ReferenceError: Undefined variable: jQuery&#60;/p&#62;
&#60;p&#62;So, I feel like we're close to getting this issue worked out, but the previously mentioned errors in the script are preventing it from working as we intended.  I'm hopeful that if we debug these errors, the script will work--at least on a single page form.  &#60;/p&#62;
&#60;p&#62;The link to the test form is below, if you'd like to take a look at it:  &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.afinspect.com/test-form/&#34; rel=&#34;nofollow&#34;&#62;All Flooring Inspections&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;You can use the same login information I sent to you via email to access the above test form.&#60;/p&#62;
&#60;p&#62;I also looked at the gform_page_loaded hook that you mentioned in your last post.  Can you explain how I should include that in the multi-page forms where I need the alert to show up, please?&#60;/p&#62;
&#60;p&#62;Thanks again for your help!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-43688</link>
			<pubDate>Sun, 11 Dec 2011 01:29:24 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">43688@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Greg, you asked earlier how Gravity Forms does it in the form editor.  Here's the code for that:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[js]
jQuery(document).ready(function() {
    gforms_original_json = jQuery.toJSON(form);

    window.onbeforeunload = function(){
        UpdateFormObject();
        if (gforms_original_json != jQuery.toJSON(form)){
            return &#38;quot;You have unsaved changes.&#38;quot;;
        }
    }
});&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This is present in the plugin in js/form_editor.js.  It checks to see if the original JSON is the same as what is currently present in the page (i.e. if there were any changes in the editor) and if there were, pop up the dialog that says &#34;You have unsaved changes.&#34; on line one, and the browser default message on line 2.&#60;/p&#62;
&#60;p&#62;I believe that code will work for you (with modifications maybe), but you need to have that code present on all pages of a multi-page form?   For that, you can use the &#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Gform_page_loaded&#34; rel=&#34;nofollow&#34;&#62;gform_page_loaded&#60;/a&#62; hook.  &#60;/p&#62;
&#60;p&#62;You also mentioned that it was only working in Safari.  Can you explain what happens in the other browsers, or post a link to a form online where you have implemented this, so we can check it for errors?  You can email me again if you like &#60;a href=&#34;mailto:chris@rocketgenius.com&#34;&#62;chris@rocketgenius.com&#60;/a&#62; - thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>greg on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-43326</link>
			<pubDate>Wed, 07 Dec 2011 13:08:11 +0000</pubDate>
			<dc:creator>greg</dc:creator>
			<guid isPermaLink="false">43326@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Chris,&#60;/p&#62;
&#60;p&#62;I just wanted to make sure you received my email on Monday, and that you were able to access the forms.&#60;/p&#62;
&#60;p&#62;Thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-43155</link>
			<pubDate>Mon, 05 Dec 2011 16:46:58 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">43155@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Sure, please sent an email to &#60;a href=&#34;mailto:chris@rocketgenius.com&#34;&#62;chris@rocketgenius.com&#60;/a&#62; and I will take a look.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>greg on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-43139</link>
			<pubDate>Mon, 05 Dec 2011 13:47:43 +0000</pubDate>
			<dc:creator>greg</dc:creator>
			<guid isPermaLink="false">43139@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for your reply, Chris.&#60;/p&#62;
&#60;p&#62;I'll be glad to provide a link to the form for support purposes.  Some of the questions on the form are proprietary, though, so I have the forms on password protected pages. &#60;/p&#62;
&#60;p&#62;Would it be possible to send a link and login information to you via email?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-43066</link>
			<pubDate>Sun, 04 Dec 2011 16:07:21 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">43066@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Can you post a link to your form please so we can see what's going on? Thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>greg on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-42893</link>
			<pubDate>Fri, 02 Dec 2011 14:39:44 +0000</pubDate>
			<dc:creator>greg</dc:creator>
			<guid isPermaLink="false">42893@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for your reply, Carl.&#60;/p&#62;
&#60;p&#62;Unfortunately, I haven't had any luck with the script I linked to above.  I did try another script (the jQuery script below), which seems to work fine in Safari, but doesn't work at all in Firefox, Opera, or IE.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;
	$(&#38;#39;#reload&#38;#39;).click(function() {
	 	location.reload();
	});
	$(window).bind(&#38;#39;beforeunload&#38;#39;, function(){
		return &#38;#39;&#38;gt;&#38;gt;&#38;gt;&#38;gt;&#38;gt;Before You Go&#38;lt;&#38;lt;&#38;lt;&#38;lt;&#38;lt;&#38;lt;&#38;lt;&#38;lt; \n Your custom message go here&#38;#39;;
	});
&#38;lt;/script&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I'm stuck (from a code perspective), and would greatly appreciate some advice on moving forward with this challenge.&#60;/p&#62;
&#60;p&#62;I think having this as a built-in form option in future releases would be very valuable.  It's frustrating for a user to be half way done with a multi-page form and lose their data, because they accidentally clicked a link or closed the window/tab.&#60;/p&#62;
&#60;p&#62;For what it's worth, I believe a nearly identical feature is already built in to the back end admin panel of Gravity Forms.  When editing a form, a confirm dialog is displayed when trying to exit/refresh the page before hitting the &#34;Update Form&#34; button--but the confirm dialog is not displayed when the &#34;Update Form&#34; button has been submitted.  This seems to be exactly what I'm trying to do, only on the front end...&#60;/p&#62;
&#60;p&#62;Can you point me in the right direction on how I can make this work, please?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Javascript alert when leaving multiple page form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/javascript-alert-when-leaving-multiple-page-form#post-42774</link>
			<pubDate>Thu, 01 Dec 2011 17:05:23 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">42774@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You should be able to use standard javascript or jQuery to accomplish this.  Gravity Forms outputs standard HTML so customizations can be implemented using jQuery. So this should be doable.&#60;/p&#62;
&#60;p&#62;I would suggest playing around with it on a test form or a test site and see if you can get it to work.  It certainly can't hurt to experiment and try.&#60;/p&#62;
&#60;p&#62;What you describe may make a good built in feature as a form option.  If a user has started filling out a form and then tries to navigate away without submitting it, display this type of alert.  I'll note this feature idea for future reference.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
