Java Reference
In-Depth Information
Here window is in front just to make it clear what you are actually accessing. It would be very easy when
reading the code to mistake status for a variable, so in this situation, although it isn't strictly necessary,
putting window in front does make the code easier to read, understand, and therefore debug.
Problems with Firefox and the blur Event
The previous example will fail with Firefox if you enter a name in the name text box and then an invalid
age into the age box (for example, if you enter abc and then click the Check Form button). With Internet
Explorer (IE) the blur event fi res and displays an alert box if the age is invalid, but the button's click event
doesn't fi re. However, in Firefox, both events fi re with the result that the invalid age alert is hidden by the
“form completed successfully” alert box.
In addition, if you enter an invalid age for both IE and Firefox browsers and then switch to a different
program altogether, the “invalid age” alert box appears, which is annoying for the user. It could be that
the user was opening up another program to check the details.
Although this is a fi ne example, it is not great for the real world. A better option would be to check the
form when it's fi nally submitted and not while the user is entering data. Or, alternatively, you can check
the data as they are entered but not use an alert box to display errors. Instead you could 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. In Chapter 12 you'll see how to write to the page
after it's been loaded.
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 pass-
word is sent as plain text — there is no encryption or any attempt at hiding the text (unless the page is
served over a secure connection from the server).
Defi ning a password box is identical to defi ning a text box, except that the type attribute is password.
<input name=”password1” type=”password” />
This form element creates an associated Password object, which is identical to the Text object in its
properties, methods, and events.
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 defi ne a hidden text box, you use the following HTML:
<input type=”hidden” name=”myHiddenElement” />
Search WWH ::




Custom Search