Skip to content

Instantly share code, notes, and snippets.

@ckdake
Created January 18, 2011 20:45
Show Gist options
  • Save ckdake/785110 to your computer and use it in GitHub Desktop.
Save ckdake/785110 to your computer and use it in GitHub Desktop.
// Form dirtyness tracking
$('form *').change( function() {
window.formDirty = true;
});
$('form input').click( function() {
if (this.name == "commit") {
window.formDirty = false;
}
});
window.onbeforeunload = function() {
if ( window.formDirty ) {
return "You have unsaved changes. Navigating away from this page will loose them."
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment