Working with Text Fields
Text fields are single-line widgets for text input, as in Figure 68.13. Text fields are probably the most common widget on the Web.
Figure 68.13. Use text fields for single-line text input.
[View full size image]
Listing 68.13. View Source for Figure 68.13.
When you click inside a text field, the browser doesn't automatically select the entire string of text in the field. This is often inconvenient when your text fields contain preset values, because the visitor has to clear out the old information before typing in new information. A simple line of JavaScript remedies this problem nicely:
<form>
<input type="text" name="typeTextHere" value="Type text here." size="50" maxlength="80">
</form>
[View full width]<input type="text" name="typeTextHere" value="Type text here." size="50" maxlength="80"
onFocus="this.select();">
|
TIPYou can add onFocus="this.select();" to password fields and text areas, too. |