HTML Form Attribute
The form attribute specifies the form the element belongs to. The value of this attribute must be equal to the id attribute of a <form> element in the same document.
Types of attributes:
- Action
- method
- Target
- autocomplete
- nonvalidate
The action Attribute
The action attribute defines the action to be performed when the form is submitted. Usually, the form data is sent to a file on the server when the user clicks on the submit button.
<form action="index_page.php">
<label> name </label>
<input type="text">
<label> city </label>
<input type="text">
<input type="button" value="submit">
</form >
The Method Attribute
The method attribute specifies the HTTP method to be used when submitting the form data.
There are 2 types of method attributes
- method="GET"
- method="POST"
<form action="index_page.php" method="GET"> </form >
<form action="index_page.php" method="POST"> </form >
The target Attribute
The target attribute specifies where to display the response that is received after submitting the form.
Target attribute values:
- _blank A new window or tab.
- _self Current window.
- _parent A parent frame.
- _top full body of the window.
- framename A named Iframe.
_self target example
<form action="index_page.php" target="_self"> </form >
The autocomplete Attribute
The autocomplete attribute specifies wheather a form and input field should have autocomplete or not.
when autocomplete is on browser automatically complete the input field as user entered before.
<form action="index_page.php" autocomplete="on"> </form >
The nonvalidate Attribute
The nonvalidate attribute specifies that the submitted form data should not be valid when submitted.
This is a boolean atribute.
<form action="index_page.php" nonvalidate> </form >