Created
August 23, 2011 19:36
-
-
Save xeoncross/1166265 to your computer and use it in GitHub Desktop.
Alert user about unsaved form changes!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isDirty = false; | |
| $(document).ready(function() | |
| { | |
| // Alert user about unsaved changes! | |
| $(':input').change(function(){ | |
| if(!isDirty) isDirty = true; | |
| }); | |
| window.onbeforeunload = function(){ | |
| if(isDirty) return 'You haven\'t saved your changes.'; | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment