Why not to rely on the value of a Submit button
Posted by Streetdaddy™ on June 10th, 2004 filed in WebCame across an interesting usability issue with a website at work today. Consider this simple search form with one text field and a Submit button:
<form> </form>
When the form was submitted our system used the value of the Submit button, named ‘fromweb’, to test that the form had been submitted. As long as the value wasn’t null, then we could be reasonably sure the form had been submitted. Herein lies the problem…
All modern browsers allow you to submit a form by pressing the Enter key when a text field in the form has focus. However Internet Explorer 5 and above won’t pass the value of the Submit button unless the button is clicked by the user. So if the form was submitted by pressing Enter on the keyboard then our system couldn’t test for the ‘fromweb’ value.
I don’t think I would consider doing things that way anyway, but at least I now know that I shouldn’t! What I’ve learnt is:
Never rely on the value of a Submit button. Always use hidden fields to pass the value instead
For example:
<form> </form>
With this method you can be sure that the value will be passed through regardless of how the user submitted the form.

Leave a Comment