If humans could fill out forms perfectly on the first try, there would be no erasers on pencils and no backspace key on your computer keyboard. You can give your visitors a reset button so that they can start over with a fresh form (including all the default values you've set).
To create a reset button:
Type <input type="reset".
If desired, type value="reset message" where reset message is the text that appears in the button. The default reset message is Reset.
Figure 17.46. You can use the value attribute to set any text you wish for the reset button.
Figure 17.47. The CSS from Figure 17.41 on page 272 already applies to the Reset button. No additions are necessary.
Figure 17.48. If your visitor clicks the reset button, all the fields are set to their default values.
The name-value pair for the reset button is only sent to the script if you set the name attribute. Therefore, if you omit the name attribute, you won't have to deal with the completely superfluous reset datawhich is usually something like "reset, Reset".
You could add the name attribute to a reset button for scripting purposes (see page 316).
You can add images, font choices, and even a background color to your reset button.
To create a reset button with an image:
Type <button type="reset">.
Type the text, if any, that should appear on the left side of the image in the button.
Type <img src="/books/2/62/1/html/2/image.url", where image.url is the name of the image that will appear on the button.
Type alt="alternate text", where alternate text is what appears if the image doesn't.
If desired, add any other image attributes.
Type /> to complete the image.
Type the text, if any, that should appear on the right side of the image in the button.
Figure 17.49. Make sure you set the type to reset. Otherwise, the button won't actually do anything at all.
Figure 17.50. Now both the submit and reset buttons really stand out. (It really works, by the way. Try it on my Web sitesee page 26.)
You can also use the button tag to create a reset button without an image. Just skip steps 36.
For information on creating buttons with scripts, consult Creating a Button that Executes a Script on page 316.
Current browsers support the button tag quite well. Older browsers do not, despite it being a standard part of (X)HTML.
I can't think of any good reason to add the value attribute to a reset button, but you might want to add a name attribute for scripting purposes.