You can set the javascript variable if the form is edited. An easy way to do this would be to listen for a change event in the input fields:
var isChanged = false; $('input,select,textarea').change(function() { isChanged = true; });
And then check isChanged before submitting.
This approach does not take into account the values ββreturned back to the original value.
If you need to solve this scenario, you need to save the state of the form in a javascript object and compare it with this.
You can add this to prevent the user from leaving the page if the form has changed:
$(window).bind('beforeunload', function() { if (isChanged) { return 'You have changed the form, are you sure?'; } else { return undefined; } });
Christian dalager
source share