Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
396
Chapter 16 Using HTML Forms
TEXTAREA
in the following subsection.
TEXT
is the default
TYPE
in
INPUT
forms, although it is recommended that
TEXT
be supplied explicitly. You
should remember that the normal browser word wrapping applies inside
FORM
elements, so be careful to make sure the browser will not separate the
descriptive text from the associated textfield.
Core Approach
Use explicit HTML constructs to group textfields with their descriptive text.
Some browsers submit the form when the user presses Enter when the
cursor is in a textfield, but you should avoid depending on this behavior
because it is not standard. For instance, Netscape submits the form when the
user types a carriage return only if the current form has a single textfield,
regardless of the number of forms on the page. Internet Explorer submits the
form on Enter only when there is a single form on the page, regardless of the
number of textfields in the form. Mosaic submits the form on Enter only
when the cursor is in the last textfield on the entire page.
Core Warning
Don't rely on the browser submitting the form when the user presses Enter
when in a textfield. Always include a button or image map that submits the
form explicitly.
The following subsections describe the attributes that apply specifically to
textfields. Attributes that apply to general HTML elements (e.g.,
STYLE
,
CLASS
,
ID
) are not discussed. The
TABINDEX
attribute, which applies to all
form elements, is discussed in Section 16.11 (Controlling Tab Order).
NAME
The
NAME
attribute identifies the textfield when the form is submitted.
In standard HTML the attribute is required. Because data is always sent
to the server in the form of name/value pairs, no data is sent from form
controls that have no
NAME
.
VALUE
A
VALUE
attribute, if supplied, specifies the initial contents of the text
field. When the form is submitted, the current contents are sent; these
can reflect user input. If the textfield is empty when the form is submit
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved