<input type="text">
Browser |
|
---|---|
Type |
The INPUT element defines an input field. When you specify "text" for the type attribute of this element, a text box is created.
<input type="text" name="name1">
<input type="text" name="name2" size="30" maxlength="30" value="Example">
Attribute | Value | Explanation |
---|---|---|
type=" " | text | the type of input field (the default is "text") |
name=" " | field name | a unique name for the field |
size=" " | number of characters | the input field width |
maxlength=" " | number of characters | the maximum number |
value=" " | initial value | the text displayed in the field |
- type="text"
- Creates a text box on the form.
- name=""
- The field name is used to identify the form field.
- size=""
- The input field width is specified by the number of characters.
- maxlength=""
- Specifies the maximum number of characters allowed in the input field.
- value=""
- Specifies the initial text displayed in the input field.
Example
<form method="POST" action="example.cgi">
<p>Default<br>
<input type="text" name="example1"></p>
<p>size="30"<br>
<input type="text" name="example2" size="30"></p>
<p>maxlength="10"<br>
<input type="text" name="example3" size="30" maxlength="10"></p>
<p>value="Hello!"<br>
<input type="text" name="example4" size="30" value="Hello!"></p>
</form>
- Output
This form cannot submit because of a sample.