Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Created August 23, 2011 19:36
Show Gist options
  • Save xeoncross/1166265 to your computer and use it in GitHub Desktop.
Save xeoncross/1166265 to your computer and use it in GitHub Desktop.
Alert user about unsaved form changes!
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