Writing about the reset button which appears on some web forms, and which clears all form fields when pressed, mblase states, "There is almost never any reason for an end user of your HTML forms to want to clear the form". This is absolutely true; and even if an end user were to make a mistake in one of the form fields, there is no earthly reason why they would then want to erase every single field on the form and start over.

Unfortunately though, clients commissioning web sites sometimes get a bad idea into their heads and absolutely refuse to let it go, ignoring the advice of the very people that they have employed to advise them on such matters. And high on the list of bad ideas that clients demand is the reset button. They’ve seen them on other sites, and have therefore decided that if they want to be taken seriously they’d better have one on their site too.

My policy regarding this is to suggest that it is not really necessary, explain why (if asked), and leave it at that. Cynical though that may sound, my days of fighting with clients in order to do them a favor are over. That doesn’t mean I ignore the needs of the end users though: what I now do is to try and minimize the impact of the reset button as much as possible.

Instead of a reset button, I add a scripted button with a simple confirm() handled by onClick :


<input type="button" value="reset" onClick="if (confirm('Do you really want to clear the entire form?')) {this.form.reset()}">


It's a little clumsy, but receiving a confirm request is definitely less frustrating for the user than clearing an entire form by mistake.

Reset() is supported in Netscape Navigator from version 3 onwards and Internet Explorer from version 4, so this ought to catch the majority of users. Be aware though that some earlier browsers may well give an error: so depending on the circumstances and likely use, it may be desirable to test for compatibility first and script accordingly.