The <form> element defines an HTML form:
<form>
<!-- form elements here -->
</form>
Note: The form itself is not visible, only its children
Form - a set of fields for text entry, command buttons, check boxes, etc., whose contents are returned to the server as directed by the user. The server further processes the information and, if necessary, returns the user answers.
The form intended to exchange data between the user and the server. A document may contain any number of forms, but at the same time on the server can be sent to only one form.
The method attribute specifies the HTTP method (GET or POST) to be used when submitting the forms:
<form action="action_page.php" method="get">
or
<form action="action_page.php" method="post">
You can use GET (the default method):
action_page.php?firstname=Mickey&lastname=Mouse
GET is best suited to short amounts of data. Size limitations are set in your browser.
You should use POST:
To be submitted correctly, each input field must have a name attribute.
This example will only submit the "Last name" input field:
An HTML <form> element, with all possible attributes set, will look like this:
<form action="action_page.php" method="GET" target="_blank" accept-charset="UTF-8"
enctype="application/x-www-form-urlencoded" autocomplete="off" novalidate>
<!-- form elements here -->
</form>
Attribute | Description |
---|---|
accept-charset | Specifies the charset used in the submitted form (default: the page charset). |
action | Specifies an address (url) where to submit the form (default: the submitting page). |
autocomplete | Specifies if the browser should autocomplete the form (default: on). |
enctype | Specifies the encoding of the submitted data (default: is url-encoded). |
method | Specifies the HTTP method used when submitting the form (default: GET). |
name | Specifies a name used to identify the form (for DOM usage: document.forms.name). |
novalidate | Specifies that the browser should not validate the form. |
target | Specifies the target of the address in the action attribute (default: _self). |
<input type="radio"> defines a radio button
Radio buttons let a user select ONE of a limited number of choices:
<input type="text"> defines a one-line input field for text input:
The default width of a text field is 20 characters.
The <input> element is the most important form element.
The <input> element has many variations, depending on the type attribute.
Type | Description |
---|---|
text | Defines normal text input |
radio | Defines radio button input (for selecting one of many choices) |
submit | Defines a submit button (for submitting the form) |
Used to change the value of the check boxes and radio buttons when you click the mouse on the text.
There are two methods of binding an object and labels:
The <select> element defines a drop-down list:
The <textarea> element defines a multi-line input field (a text area)
The <button> element defines a clickable button
The <fieldset> element groups related data in a form.
The <legend> element defines a caption for the <fieldset> element.
The value attribute specifies the initial value for an input field:
The readonly attribute specifies that the input field is read only (cannot be changed):
The size attribute specifies the size (in characters) for the input field:
With a maxlength attribute, the input control will not accept more than the allowed number of characters.
The maxlength attribute specifies the maximum allowed length for the input field:
HTML5 added the following attributes for <input>:
The novalidate attribute is a <form> attribute.
When present, novalidate specifies that form data should not be validated when submitted.
The autofocus attribute is a boolean attribute.
When present, it specifies that an <input> element should automatically get focus when the page loads.
The height and width attributes specify the height and width of an <input> element.
The height and width attributes are only used with <input type="image">.
The list attribute refers to a <datalist> element that contains pre-defined options for an <input> element.
It contains a base workspace and an extensible plug-in system for customizing the environment.
Eclipse is written mostly in Java and its primary use is for developing Java applications, but it may also be used to develop applications in other programming languages through the use of plugins
Create this page
Save image to get better quality
Registration form
Searching
Form
Save image to get better quality