Loss of typing online
How many times has this happened to you?
You print a long block of text in a form on a web page, and you click next or submit or whatever. Then an error occurs. So you hit the back button to fix the bug and your whole version is gone!
Today I heard a colleague swear in our help software because he typed a long solution and got an error when he lost the text.
I told him that this had happened to me so many times that if I noticed that I was typing a lot, I would open a notebook and type it all in, then copy it.
So I was wondering if there is anything a web developer can do to protect against this? I never thought about this while programming, but I would like to keep this in mind in the future.
What we can do?
a source to share
There are two key ways to do things:
-
Keep the session awake by lengthening the session time (bad) or checking the page server before the session expires (better).
-
Process the session before processing the form on submission. If I suspect this is because the user is logged out, keep a cookie handy to make sure you can register that user before thinking about touching the form data.
And most importantly (for both of the above), save the state of the form when it's submitted !! That way, even if something explodes, you can provide a "back to form" link and pump all the data right into the form.
a source to share
ASP.NET does this automatically by keeping the Webform ViewState.
Check out this relevant page that discusses this issue at W3schools.
So my suggestions would be as follows:
-
Make sure ViewState is enabled for forms that require user input (especially those where they have to enter a lot of things).
-
Test this usability issue by injecting validators that start the backend and then enter invalid data. The entered data on the page should remain intact after the response from the server.
a source to share
Most good frameworks will keep you logged in even after an error occurs. Asp.net does this too. As a developer, when you accept input, do not be redirected to another page.
Asp.net will get the data from the viewstate and put it in place.
The problem you mentioned (requires a click) happened because your application may have presented you with a different page.
Validation errors (in my opinion) are best shown:
- at the top of the page
- next to the element with error
- as a modal div.
This will preserve the viewstate and users won't have to rewrite the data.
This also happens in many php frameworks.
a source to share
So you press back to fix the bug and your whole version is gone!
Not with Firefox (in general ...), it stores the typed data and shows it back when you return to the previous page.
If some silly JavaScript is erasing the contents of the field when getting focus or similar!
Better yet, I use It All Text! an extension that adds a button to the text boxes, allowing me to edit the text in a handy real text editor ... (and update the box on every save).
Now, for other users, you should follow the guidelines ...
But I would add something for another general case: you type something long in the browser and inadvertently close the tab / window or your browser / computer crashes, etc.
Sun Forums have the nice feature of regularly sending the content of the text field to the server using Ajax. Therefore, if you return to your page, the server can restore your work even if you haven't submitted anything yet.
a source to share