demosthenes.info

A blog by Dudley Storey on , , , , , , and anything else that strikes his fancy.

featured articles

popular favourites

HTML Forms: submit & reset

When all is said and done, the user needs to indicate that they are finished entering information with the form and want to submit it. This is done with a submit button, which is usually the last (or second-to-last) tag before the closing </form> tag:

  1. <input type = "submit" />

The value attribute of the submit button is the text displayed on the button itself. This value should be assigned, since different browsers will make different assumptions about the displayed text otherwise (Most browsers will assume that the text should be “Submit Query”).

  1. <input type = "submit" value="Go!" />

While it is not necessary to place an id or name on the submit button, doing so can be useful for the purposes of validating the form information, which I cover in the PHP section.

Reset

A reset button sets the form back to its default settings. Be very careful where you place a reset button: too close to the submit button and some users will inevitably accidentally click on it rather than the submit button by mistake, and there is no way to get back their information once they have done so. Physically separate the submit and reset buttons with a space at the very least, or skip the reset button entirely.

  1. <input type = "reset" value="Reset page" />

web developer guide

featured comment

by JoelB in Goodbye, JQuery Validation: HTML5 Form Errors With CSS3

what i'm reading

A Storm of Swords: A Song of Ice and Fire: Book Three
A Storm of Swords: A Song of Ice and Fire: Book Three

what i'm watching

Californication: The Third Season
Californication: The Third Season

what i'm playing

Mass Effect 3 Collector's Edition
Mass Effect 3 Collector's Edition

what i'm hearing

Dub FX
Dub FX

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.