Is there anyway to check any of the HTML components (i.e input elements) value in a form got changed so that i can pop up a alert saying "would like to save changes?" before navigating to other page.
Thanks.
Is there anyway to check any of the HTML components (i.e input elements) value in a form got changed so that i can pop up a alert saying "would like to save changes?" before navigating to other page.
Thanks.
Since you have jQuery in your question:
After page load, use $.serialize to create a snapshot of the form.
On submit, run serialize again.
Then you can use use (or create) an isEqual function to compare if there has been a change.
This question might help you on that last step: How to determine equality for two JavaScript objects?
EDIT
jQuery also has a serializeArray method which may make that process easier.
 
    
     
    
    jQuery('.form_component').change(function (){..}); , where form_component should be a class common for all your input elements in the form.
