What a form does
Submit buttons
Use button types deliberately so primary submission, secondary actions, and reset behavior do not surprise the visitor.
8 minute lesson
A button inside a form submits by default. I still write the type because it makes the intent clear and prevents surprises when markup moves.
<button type="submit">Publish</button>
<button type="button" id="preview">Preview</button>
The first button submits the form. The second does nothing until JavaScript gives it behavior.
Several submit buttons can send different actions to one endpoint:
<button type="submit" name="action" value="draft">Save draft</button>
<button type="submit" name="action" value="publish">Publish</button>
Only the submitter that started the submission contributes its name and value. The server can read action, then check whether that action is allowed for the current user and record.
Do not trust the button value as authorization. Someone can send action=publish without clicking the visible button.
Avoid type="reset" in most forms. It restores the initial values, which can erase several minutes of work without saving anything. A clearly labeled “Clear form” action may be justified, but it should be hard to trigger accidentally.
Also test keyboard submission. Pressing Enter in a field can submit without a pointer click, which is why form-level submit handling matters more than button click handling.
Lesson completed