SCRIPTING TEXT BOXES
There are two ways to represent text boxes in HTML: a single-line version using the <input>
element and a multiline version using <textarea>
. These two controls are very similar and behave in similar ways most of the time. There are, however, some important differences.
By default, the <input>
element displays a text box, even when the type
attribute is omitted (the default value is "text"
). The size
attribute can then be used to specify how wide the text box should be in terms of visible characters. The value
attribute specifies the initial value of the text box, and the maxlength
attribute specifies the maximum number of characters allowed in the text box. So to create a text box that can display 25 characters at a time but has a maximum length of 50, you can use the following code:
<input type="text" size="25" maxlength="50" value="initial value">
The <textarea>
element always renders...