The form
attribute is used to specify the form that the input element belongs to. Its value is the id
attribute of the form.
Example:
<form id="myForm">
<input type="text" name="username" form="myForm">
</form>
The formaction
attribute is used to specify the URL that will process the form data when the form is submitted. It overrides the action
attribute of the form.
Example:
<form action="/submit-form" method="POST">
<input type="text" name="username">
<input type="submit" value="Submit" formaction="/submit-form-ajax">
</form>
The formenctype
attribute is used to specify the encoding type of the form data when the form is submitted. The possible values are application/x-www-form-urlencoded
, multipart/form-data
, and text/plain
.
Example:
<form action="/submit-form" method="POST" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Upload">
</form>
The formmethod
attribute is used to specify the HTTP method to use when submitting the form. The possible values are get
and post
.
Example:
<form action="/search" method="get">
<input type="text" name="query">
<input type="submit" value="Search">
</form>
The formnovalidate
attribute is used to disable form validation when the form is submitted.
Example:
<form action="/submit-form" method="POST">
<input type="text" name="username" required>
<input type="submit" value="Submit" formnovalidate>
</form>
The formtarget
attribute is used to specify the target window or frame where the response to the form submission will be displayed.
Example:
<form action="/submit-form" method="POST" target="_blank">
<input type="text" name="username">
<input type="submit" value="Submit">
</form>