Java Reference
In-Depth Information
write out a warning in red next to the erroneous input control, informing the user of the invalid
data, and then also get your code to check the form when it's submitted.
The password Text Box
The only real purpose of the password box is to enable users to type in a password on a page and to
have the password characters hidden, so that no one can look over the user's shoulder and discover
his or her password. However, this protection is visual only. When sent to the server, the text in the
password is sent as plaintext—there is no encryption or any attempt at hiding the text (unless the
page is served over a secure connection from the server).
Defining a password box is identical to defining a text box, except that the type attribute is
password :
<input name="password1" type="password" />
This form element creates an <input/> element object and has the same properties, methods, and
events as normal text boxes.
The Hidden Text Box
The hidden text box can hold text and numbers just like a normal text box, with the difference
being that it's not visible to the user. A hidden element? It may sound as useful as an invisible
painting, but in fact it proves to be very useful.
To define a hidden text box, you use the following HTML:
<input type="hidden" name="myHiddenElement" />
The hidden text box creates yet another <input/> element object, and it can be manipulated in
JavaScript like any other object—although, you can actually set its value only through its HTML
definition or through JavaScript. As with a normal text box, its value is submitted to the server
when the user submits the form.
So why are hidden text boxes useful? Imagine you have a lot of information that you need to obtain
from the user, but to avoid having a page stuffed full of elements and looking like the control panel
of the space shuttle, you decide to obtain the information over more than one page. The problem is,
how do you keep a record of what was entered in previous pages? Easy—you use hidden text boxes
and put the values in there. Then, in the final page, all the information is submitted to the server—
it's just that some of it is hidden.
the textarea element
The <textarea/> element allows multi‐line input of text. Other than this, it acts very much like the
text box element.
However, unlike the text box, the <textarea/> element has its own tag, the <textarea> tag, and
it creates an HTMLTextAreaElement object. It also has two additional attributes: cols and rows .
The cols attribute defines how many characters wide the text area will be, and the rows attribute
defines how many character rows there will be. You set the text inside the element by putting
 
Search WWH ::




Custom Search