Warning a user when navigating away from a Drupal form without saving

Normal users are not like us. We know that if we leave a page before submitting a form, the data we have added will be lost. Normal users might be happily filling in a web form, get half way through, get distracted and then click on a link and lose their data. Ok, maybe they are exactly like us, because I have done this as well. We are all busy. We all get distracted.

A helpful reminder is in order - a simple popup with a warning, alerting the user to the fact that if they leave the current page, they will lose the data on the form.

You could write some Javascript to do this. There is a bunch of tutorials and stackoverflow posts about this. Or, if you are using Drupal, you could just download and enable Node Edit Protection, which will do it all out of the box.

Node Edit Protection will display a Javascript dialog with two options - stay on the page or leave and lose the data. If you click "Stay on the this page", you can carry on filling in the form, no harm done. If you click "Leave this Page", you will lose your data, but at least you have been warned.

Confirm when navigating away from unsaved Drupal form

Check out Node Edit Protection

Comments

Thanks for sharing!
It isn't always a users deliberate choice to navigate away, what about pressing delete, while the textarea didn't have focus.. Just happened to me today, going to install this plugin right away

Add new comment