Form
Connects an <input> to a specific <form> (even if the input is outside the form).
👉 The value must match the id of the <form>
<Form action="/action_page.php" id="form1">
<input type="text" name="fname">
<input type="submit" value="submit">
<input type="text" name="lname" form="form1">
</Form>
formaction
Defines a different URL for submitting the form.
👉 Overrides the form's action attribute
👉 Works with type="submit" and type="image".
<Form action="/action_page.php">
<input type="submit" value="Normal Submit">
<input type="submit" formaction="/admin_page.php" value="Submit as Admin">
</Form>
formenctype
Specifies how form data should be encoded (only with method="post")
Overrides form's enctype.
Works with submit and image types.
Common value:
- multipart/form-data` (used for file uploads)
<form action="/upload.php" method="post">
<type="submit" value="Normal Submit">
<input type="submit" formenctype="multipart/form-data" value="Upload File">
</form>
formmethod
Defines the HTTP method (`get` or `post`).
Overrides form's method.
GET
- Data added in URL
- Visible in address bar
- Not secure
- Limited size
POST
- Data sent in HTTP body
- More secure
- No size limit
- Cannot bookmark
<form action="/action.php" method="get">
<tinput type="submit" value="Submit using GET">
<input type="submit" formmethod="post" value="Submit using POST">
</form>
formtarget
Specifies where to display the response.
Common values:
- _self (same page)
- _blank (new tab)
<form action="/action.php">
<input type="submit" value="Submit">
<input type="submit" formtarget="_blank" value="Open in New Tab">
</form>
formnovalidate
Disables validation for that specific submit button.
<form action="/action.php">
<input type="email" name="email">
<input type="submit" value="Validate">
<input type="submit" formnovalidate value="Submit without Validation">
</form>
Novalidate (Form Attribute)
Disables validation for the whole form.
<form action="/action.php" novalidate>
<input type="email" name="email">
<input type="submit">
</form>
Quick Summary Table
| Attribute |
Purpose |
| form |
Connect input to form |
| formaction |
Change submit URL |
| formenctype |
Change encoding type |
| formmethod |
Change GET/POST |
| formtarget |
Change response location |
| formnovalidate |
Disable validation (button only) |
| formenctype |
Disable validation (whole form) |