What Is The HTML Form Attributes
This part depicts the various qualities for the HTML Form <form> component.
The Action Attribute
The activity trait characterizes the activity to be performed when the structure is submitted.
Typically, the structure information is shipped off a document on the worker when the client taps on the submit button.
In the model underneath, the structure information is shipped off a record called “action_page.php”. This document contains a worker side content that handles the structure information:
Example
On submit, send form data to “action_page.php”:<form action=”/action_page.php”>
<label for=”fname”>First name:</label><br>
<input type=”text” id=”fname” name=”fname” value=”John”><br>
<label for=”lname”>Last name:</label><br>
<input type=”text” id=”lname” name=”lname” value=”Doe”><br><br>
<input type=”submit” value=”Submit”>
</form>
Tip: If the action
attribute is omitted, the action is set to the current page.
The Target Attribute
The objective property determines where to show the reaction that is gotten subsequent to presenting the structure.
The objective trait can have one of the accompanying qualities:
Value | Description |
---|---|
_blank | The response is displayed in a new window or tab |
_self | The response is displayed in the current window |
_parent | The response is displayed in the parent frame |
_top | The response is displayed in the full body of the window |
framename | The response is displayed in a named iframe |
The default value is _self which implies that the reaction will open in the current window.
Example
Here, the submitted result will open in another program tab:<form action=”/action_page.php” target=”_blank”>
The Method Attribute
The technique property indicates the HTTP strategy to be utilized while presenting the structure information.
The structure information can be sent as URL factors (with method="get"
) or as HTTP post transaction (with method="post"
).
The default HTTP technique when submitting structure information is GET.
Example
This model uses the GET strategy while presenting the structure information:<form action=”/action_page.php” method=”get”>
Example
This model uses the POST strategy while presenting the structure information:<form action=”/action_page.php” method=”post”>
Notes on GET:
- Adds the structure information to the URL, in name/esteem sets
- NEVER use GET to send delicate information! (the submitted structure information is noticeable in the URL!)
- The length of a URL is restricted (2048 characters)
- Valuable for structure entries where a client needs to bookmark the outcome
- GET is useful for non-secure information, similar to question strings in Google
Notes on POST:
- Attaches the structure information inside the body of the HTTP demand (the submitted structure information isn’t displayed in the URL)
- POST has no size impediments, and can be utilized to send a lot of information.
- Structure entries with POST can’t be bookmarked
Tip: Always use POST if the form data contains sensitive or personal information!
The Autocomplete Attribute
The autocomplete quality determines whether a structure ought to have autocomplete on or off.
When autocomplete is on, the program consequently complete qualities dependent on qualities that the client has entered previously.
Example
A form with autocomplete on:<form action=”/action_page.php” autocomplete=”on”>
The Novalidate Attribute
The novalidate quality is a boolean characteristic.
At the point when present, it indicates that the structure information (input) ought not be approved when submitted.
Example
A form with a novalidate attribute:<form action=”/action_page.php” novalidate>