[ic] Warn before navigating away if form data not submitted ?

Bill Carr bill at bottlenose-wine.com
Thu May 20 20:33:57 UTC 2010


On May 20, 2010, at 3:58 PM, DB wrote:

> I'm seeking a way to warn a user if they attempt to navigate away from a
> page which has form data that's not yet been submitted. A javascript
> popup for example would do the trick, or maybe there's a way to do this
> using an IC trick? I'd welcome any thoughts or ideas.
Some untested Javascript:

	<script type="text/javascript" charset="utf-8">
		var formChanged = 0;
		var submitted = 0;
		window.onbeforeunload = function () {
			if (!submitted && formChanged) {
				return "You have unsaved changes.";
			}
			return;
		}
	</script>
 

<form onsubmit="submitted = 1;">
	<input name=somefield onchange="formChanged = 1;">

</form>

Bill Carr 
Bottlenose - Wine & Spirits eBusiness Specialists 
(413) 584-0400 
http://www.bottlenose-wine.com 



More information about the interchange-users mailing list