HTML5 Form Attributes
This article describes the different attributes for the
<form>
tag.
-
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.
-
The target attribute
The target attribute specifies where to display the response that is received after submitting the form.
The target attribute can have one of the following values:
- _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 method attribute specifies the HTTP method to be used when submitting the form data.
The form-data can be sent as URL variables (with method="get") or as HTTP post transaction (with method="post").
The default HTTP method when submitting form data is GET.
-
The autocomplete atttribute
If it is "on", the form fields will gain suggestions in a dropdown box as you type characters in a text field.
Example:
<form action="/action_page.php" autocomplete="on">
-
The novalidate attribute is a boolean attribute.
When present, it specifies that the form-data (input) should not be validated when submitted
Example:
<form action="/action_page.php" novalidate>
-
The enctype attribute specifies how the form-data should be encoded when submitting it to the server.
Note: The enctype attribute can be used only if method="post"
If enctype is "application/x-www-form-urlencoded", characters are encoded before sent (spaces are converted to "+" symbols, and special characters are converted to ASCII HEX values)
"multipart/form-data" attribute value is necessary if the user will upload a file through the form
Comments
Post a Comment