Kanbritech Learn logo
HTML HTML Forms 45h track

Input Form Attributes

Write a submit button outside a form whose id is registration.

Understand the topic

Controls can be associated with a form using its id through the form attribute, even when they are outside that form in the DOM. Submit buttons can override action, method, and encoding using formaction, formmethod, and formenctype. formnovalidate skips browser validation for that submission, which can be useful for saving a draft but does not remove server checks.

Worked example

<form id="application" action="/applications" method="post">
  <label for="applicant">Name</label><input id="applicant" name="name" required>
  <button type="submit">Submit application</button>
  <button type="submit" formaction="/drafts" formnovalidate>Save draft</button>
</form>
<label for="reference">Reference</label><input id="reference" name="reference" form="application">

The external reference field belongs to application because form matches its id. The draft button selects a different endpoint and bypasses browser validation only.

Practice

Write a submit button outside a form whose id is registration.

Show a suggested answer
<button type="submit" form="registration">Send registration</button>

Common mistake

The form attribute refers to an id, not an action URL. All example endpoints require server implementation.

HTML documentation

Try Coding

Result