I'm working on a feature where the user needs to be informed that there are unsaved changes in a form in case if they decide to navigate away from the page.
I am almost done but there's a tiny problem-
I am setting a boolean dirty
on input change event.
The .change()
event will detect any kind of change, as in it doesn't keep track of changes. For example, if an input field has the original value hello
, which is modified to bye
and back to hello
, it will still set the dirty
boolean.
Is there any way where I can take a backup of the form with initial values and then compare it with itself at every change event?