This could be handled with just one boolean variable, we call it dirty bit handling. If you have observed, generally in web pages, once user performs some edit action on any of the fields the form is considered as dirty(edited)(even if data remains unchanged after editing). When user tries to navigate away from the page user is prompted if he wants to save changes.
As per the standard practice, there is no check if after editing some field if the value actually got changed or not. For eg: If user edits and appends 'xyz' to a text field and then deletes 'xyz' essentially the form data remains the same as it was before but the form is still considered as 'dirty' and user is prompted warning message when he tries to navigate away.
So, if you want to implement this things get pretty simple. You would just need to add onchange() eventhandlers to the controls and set the global boolean variable something like isDirty to true inside those eventhandlers.
Once user wants to navigate away, you can flash a message "There may be unsaved changes on current page. Do you wish to save them?". User won't be disappointed even if he notices that his edit didn't change initial data.
Answers given above implement this very behavior. And I wrote this because you seemed to have an idea to check each and every field by it's initial value to see if it was really altered after edit. Just wanted to tell you that checking every field ain't necessary at all.