Default submit, reset, type=button, and a named submit
<button>
<button type="submit" name value>
<button type="reset">
<button type="button">
<button type="submit" disabled>A button with no type is a submit button and will submit its form.
| Attribute | Description |
|---|---|
type | submit (default), reset, or button. An invalid type is treated as submit. |
name and value | If a submit button is used to submit the form, its name and value are included in the submission. |
form | The id of a form in the same document, used when the button is not a descendant of that form. |
formaction, formmethod, formenctype, formtarget, formnovalidate | Submit-button overrides for the associated form's action, method, enctype, target, and novalidate. They apply only when this button submits. |
- The Preview button has type="button" and no script. It will not submit the form. No third-party action is present.
<form>
<p>
<label for="name">Name</label>
<input id="name" name="name" type="text">
</p>
<button>Save</button>
<button type="reset">Reset</button>
<button type="button">Preview</button>
<button type="submit" name="intent" value="draft">Save draft</button>
<button type="submit" disabled>Saving</button>
</form>What this markup means
The first button has no type, so it is a submit button labelled Save. Reset restores initial control values. Preview does not submit. Save draft is another submit button whose name and value can distinguish the intent if it is the button used to submit. The disabled Saving button is not successful and cannot be activated.
Related: Tag catalog: <button>, <form>, <input>