Forms and the terrible ESC key

Have you ever experienced the horrifying feeling when somehow, after completing a form on a website for a long time, your content magically disappears?

Well, when a form contains a reset button, pressing “Esc” kills the entire form content.
Even if there’s no reset button on the form, pressing “Esc” will clear the current active field.

A simple solution is to specify inside the “form” tag:

form action=…  onreset=”return confirm(‘Reset all form fields?’)”

This will cause the browser to present a warning dialog box before actually resetting the form’s content.

Leave a Reply

Your email address will not be published. Required fields are marked *