When filling out a form, click the Cancel button. Do you need to add a confirmation box?
closed as too broad by Joel Tebbett, locationunknown, JonW♦ Aug 3 '17 at 12:32
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Several factors will influence your decision.
What is the consequence of closing this form without any warning?
If the answer is that there could be the potential for the user to lose a significant number of fields that they have completed, then this is not a great experience.
But my form only has 3 fields
The irritation level will be reduced, but any loss of data or hindrance to completing a task runs the risk of 'bouncing' your users.
They have to fill it in, our site requires it
If it's a work, education form and it simply will be completed as the user has to, then consider adding in a warning so the form doesn't simply close. The argument for optional sites where users are not compelled to use you carries the risk of them not returning, you have to balance this risk.
What's the cost of not implementing a warning? Annoying people and losing data, either implement it or be clever and save the fields in session data and ask the user if they want to complete their unfinished form, if they return.
Users can lose their progress by accidentally clicking the cancel button. Always show a confirmation box by destructive actions. This way users can never delete something by accident.
Take a look at the image below. Make the 'Non destructive action' the primary button and the destructive action the secondary action. This way users do not blindly hit enter without reading the warning.