Opening an e-mail account on any site is preceded by filling up an e-form by the user. This form asks the user’s personal details along with the desired username and password. This form consists of various input boxes, buttons, labels and option buttons. This is followed by a display of the rules and regulations, in other words; the dos and don’ts of using the e-mail account. An acceptance of this by clicking on the ‘I Agree’ button fulfils all formalities of opening the e-mail account.
There can be various kinds of forms besides an e-mail form in a web page. Forms make a web page interactive. They are displayed by using various form elements like input boxes, buttons and labels. HTML enables users to create forms with the help of these elements.
The following section involves in the creation and customization of forms:
Form Tag
Forms are the most popular way to make a web page interactive. The form tag creates a form to be input by the user. It can contain text fields, check boxes, radio buttons and more. Like any form on paper, a form on a web page allows the user to enter requested information and submit it for processing. It passes the user data to a specified URL.
Syntax: |
<form attributes></form> |
| |
|
Attributes of Form Tag
Name
The name attribute takes up the value form name. It defines a unique name for the form. It is an optional attribute.
Example: |
<form name=”registration”> </form> |
| |
|
Action
The action attribute takes up a URL as its value. It sends the data to the URL defined in action when the submit button is pressed. It is an essential attribute.
Example: |
<form action=”http://expertrating.com/registration.html”> </form>
|
| |
|
Input Tag
The <input> tag defines the start of an input field where the user can enter his data. The input tag is closed by a backslash (/) at the completion of the tag.
Syntax: |
<input attributes /> |
| |
|
Attributes of Input Tag
Type
This attribute indicates the type of the input element. The default value is “text.”
The various values of type attributes are:
Button A button is an input type that will not function without applying some extra code along with it. As button is used while scripting, the concept of buttons will be discussed in detail later.
Checkbox The checkbox value creates a checkbox which can either be on or off.
Example: |
Finance: <input type=checkbox /> |
| |
|
Hidden The Hidden value indicates that the field is hidden. It gives the user the option of hiding the value within it. Hidden is commonly used by programmers who do not want users to see the value typed. The hidden value is still submitted with other information when the submit button is clicked. It usually contains the page name and page number that the user is on.
Example: |
This is hidden: <input type=hidden /> |
| |
|
Image Image creates an image that is also a “submit” button. When the user clicks on the image, the form is submitted. It also requires the “src” attribute like the image tag.
Example: |
<input type=image src=”..graphics/myimage.jpg” /> |
| |
|
Password Password indicates that the field is used for typing a password. Password works just like the text type field, with the difference that whatever is typed is not displayed on the screen. Instead of showing what has been typed, the browser displays a series of asterisks (*), bullets (.), or some other symbol to indicate the typed but hidden values.
Example: |
Password: <input type=password /> |
| |
|
Radio Radio is used to create a series of choices out of which only one can be selected. Selecting a radio button option automatically deselects all other options. Several HTML radio buttons are created by using the same name but different values.
Example: |
| |
| <input type=radio name=”joke” value=”a”/> cricket jokes <br/> |
| <input type=radio name=”joke” value=”b”/> crazy jokes <br/> |
<input type=radio name=”joke” value=”c”/> nice jokes <br/> |
| |
|
Reset
The reset value resets the form to present it in its original form i.e. in the way before anything was typed on it.
Example: |
<input type=reset /> |
| |
|
Submit The submit value creates the submit button which submits the form to the server. There can be two submit buttons on a form. To do this, the submit button has to be given the same name but different values.
Example: |
<input type=submit value=”send it” /> |
| |
|
Text Text creates the text entry field, which is the most popular type of data entry field. Text is the default-input type. If the text field is required there is no need to specify the type.
Example: |
Enter your name: <input type=text /> |
| |
|
Name
The name attribute assigns a name to the input field. It is required in most circumstances. The name of the input field is used to send the information to the server.
Example: |
First Name: <input type=text name=”realname” /> |
| |
|
Value
Value sets the value for the input field. This sets the default value for text and password fields, the button text in submit and reset buttons, and the values of choices in radio buttons.
Example: |
<input type=submit value=”send this” /> |
| |
|
|