I\'m creating an ASP.NET website and I want to implement logic to warn the user when they are navigating away from a page they\'ve edited.
I found quite a bit of inf
Your input elements probably do not exist when the code is executed. Try using the .live function to detect changes on all input elements, or wrap your code in a $(document).ready() handler.
Example:
$('input').live("change", function () {
window.onbeforeunload = function () { return "Your changes have not been saved?" };
});
or
$(document).ready(function () {
$('input').change(function () {
window.onbeforeunload = function () { return "Your changes have not been saved?" };
});
});