Why do my web forms lose data when I hit the back button?
Last updated: 06/17/2009
A common way to allow users to correct problems with their web form submission is to tell them to use their "back button". You can also use javascript to send them back. Either way, it's a quick way to have them make changes.
The assumption here is that when they go back to the form, the data (or most of it) they entered will still be there, so they can just correct the necessary fields and re-submit. Sometimes, though, the data is "missing" - the form is empty when the user goes back.
I'm not sure of all the causes, but one thing I found is that if you do javascript validation of the form using an "onsubmit" event in the <form> tag, the problem occurs.
To work around this, I call my validation routine from the submit button - using a "onclick" event.
This may not work in all cases, but it did in mine.