HTML and CSS Reference
In-Depth Information
EXPLANATION
1
A JavaScript function called valid() is defined. It takes one parameter, a reference
to a form.
2
If the password entered by the user has a length of 0 characters, an alert message
is sent.
3
If the password entered by the user has a length of less than 6 characters, an alert
message is sent.
4
If the value of the password entered by the user contains any character that is not
an alphabetic character and not a number, an alert message is sent.
5
If the password was at least 6 characters and contained only alphanumeric char-
acters (letters and numbers), then the validation test was passed, and the user is
alerted. A value of true is returned to the onSubmit handler, allowing the form to
be submitted.
6
The HTML form called passchk is started here. Its onSubmit handler is triggered
when the user clicks the submit button.
7
The input type is a password box, called pass . This is where the user will enter his
or her password. See Figure 11.50.
Figure 11.50 The user enters a password of less than 6 characters (left) or enters a
password that contains illegal characters (right).
11.6 What You Should Know
Any Web site that is trying to sell you something will have a form. They are at the heart
of Web commerce. This chapter focused on how to create forms and different input
devices used to collect the data, textboxes, checkboxes, drop-down menus, and so on.
You learned how JavaScript can access this data and manipulate it; for example, how to
change the text in a box, verify that there was any input, stop a submission, open up
 
 
Search WWH ::




Custom Search