Created
November 8, 2012 06:36
-
-
Save samwilson/4037247 to your computer and use it in GitHub Desktop.
Prompt when leaving unsaved POST forms
This file contains 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
$("form[method='post'] :input").change(function() { | |
window.onbeforeunload = function(){ | |
return true; // Prompt if any input has changed | |
}; | |
}); | |
$("form[method='post']").submit(function() { | |
window.onbeforeunload = null; // Only remove the prompt if it's the submit button | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment