Text field in HTML

Text box is used to input characters using keyboard. There are three element of the form which are used for this purpose - one-line text field, password field and multi-line text box.
The text field
Creates an element for the user to input text.
<input type="text" parameters>
Field parameters are listed in table 1.
Table 1. Parameters of text field.
Parameter | Description |
---|---|
size | Field width. |
maxlength | Maximum number of characters allowed in the text. If you omit this parameter, you can input a string longer than the field itself. |
name | Name of the field. Designed for the form handler to identify the field. |
value | The initial text contained in the field. |
Example 1 shows how to create a text field with different parameters.
Example 1. Text field.
<form action="/cgi-bin/handler.cgi"> <b>What is your name</b><br> <input type="text" maxlength="25" size="20"> </form>
The result is shown below.
Password field
Password field is a regular text field, but all the characters are shown as asterisks. Designed that nobody would peep the password when entered.
<input type="password" parameters>
The parameters are the same as in the previous element and are shown in table 1. Example 2 shows how to create a text box for entering a password.
Example 2. Password field.
<form action="/cgi-bin/handler.cgi"> <b>Username:</b> <input type="text" maxlength="25" size="20" name="text"><br> <b>Password:</b> <input type="password" maxlength="15" size="20" name="pass"> </form>
The result of this example is shown below.
Although the input text is not shown, server receives the field data without encryption. Therefore, using this field does not provide data security and can be intercepted.
Multi-line text box
The field textarea is used to create a field for multiple line entries.
<textarea parameters> text </textarea>
Between the tags <textarea>
and </textarea>
you can put any text that will be displayed when the field loads.
Field parameters are listed in table 2.
Table 2. Parameters of the multi-line text box.
Parameter | Discription |
---|---|
name | name of the field. Designed for form handler to identify the field. |
cols | number of columns in text. |
rows | number of lines in text. |
wrap | Parameters of wrap. Possible values are:
|
Using different parameters is shown in example 3.
Example 3. Multi-line text.
<form action="/cgi-bin/handler.cgi"> <b>Enter your feedback:</b><br> <textarea rows="10" cols="45"></textarea> </form>
The result is shown below.