Here's a question for the group. We are setting up our dirty fields checks for a multi-page form. We are setting it to be triggered when the user tries to navigate away, close tab, etc. One case that came up is the case of cancel. I am of the opinion that if someone clicks on cancel, they are implicitly saying that they want to leave and abandon (not save) all of their work. So asking them "do you want to save" adds an extra (and extra-annoying) step. Members of my team, however, are concerned about the possiblity of users canceling out accidentally and losing their work. This is a fair concern, but I suspect that the number of folks who explicitly want to leave the page without saving and who, thus, would be annoyed by the extra dialog, would be much bigger than the group that accidentally hit 'cancel' accidentally. What do you all think?
A simpler solution would be just auto save the form data at regular intervals so that even if your users accidentally click out and then return they can continue using the form at the state they were at.
Smashing magazine has this nice solution on how you could ensure autosaves on forms - Auto-Save User’s Input In Your Forms With HTML5 And Sisyphus.js
However in the case of cancel since its an explicit instruction to abandon a form, asking a person to confirm it would annoy them even more and prevent them from leaving immediately which was their expected behavior. That said, design your from in such a way that cancel is not accidentally clicked while the user was trying to submit a form or go to the next page.
That said I strongly recommend reading this article on UX Movement which recommends against the cancel button on forms. To quote the article
Cancel is really only needed if there's a strong reason to navigate back to where you came from. If that's needed, then I agree with you, there's (usually) no need for a 'are you sure?' type of annoyance.
If the concern is people accidentally selecting 'cancel' when they meant 'save' then this is perhaps a visual design challenge. Make sure there's no visual confusion between the two and that they aren't so close in proximity that stray clicks/taps are an issue.