I have a form generated by <% Ajax.BeginForm() {} %>
which contains a lot of inputs and texareas.
When an input value change, I need to know about it
From jQuery Docs:
//This applies to whole form
$('#formID').change(function() {
alert('Form changed!');
});
And you could do like this to check only the inputs and have user notified, if they try to exit without saving changes.
var inputsChanged = false;
$('#formID input').change(function() {
inputsChanged = true;
});
$(window).unload(function() {
if (inputsChanged === true) {
alert('Would you like to save your edits before exiting?');
}
});
jQuery API .change()