Text field in HTML

Text field in HTML
 
Text field in HTML
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


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.

What is your name

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.

Username:
Password:

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:

  • off - disables word wrap;
  • virtuals - shows line breaks, but sends the text as it is;
  • physical - line breaks are placed where indicated, then sends this text.

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.

Enter your feedback:

 

Read also

Adding a form to a page in HTML

Adding a form to a page in HTML

Buttons in HTML

Buttons in HTML

Form elements in HTML

Form elements in HTML

Checkboxes in HTML

Checkboxes in HTML

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation