Reputation: 872
In the app I'm working on, the first thing a user needs to do after authenticating is to enter a name in an input form and save it.
If the user tries to leave the form without having entered something and saved it, I would like to be able to detect this behavior and prevent it, possibly with an alert that reminds them they must first save the form (and not give them a choice).
I know how to use jquery .change() to check if the contents of an input box have changed, but I don't know how to check to see if nothing has changed.
Upvotes: 0
Views: 771
Reputation: 58595
You have to store the initial state of each input element and then test for it.
I've written a jsfiddle that does that for checkboxes, but you'll get the point.
Upvotes: 2