HTML and CSS Reference
In-Depth Information
EXPLANATION
7
This is the big function that returns the final verdict. Did the user provide a valid
e-mail address and phone number? If so, the function returns
true
, line 14.
8
The
ok_Email()
function is called with the user's e-mail input. If the
ok_Email()
function returns
false
, the user entered an invalid address, and will be alerted.
9
The alert dialog box sends this message if the e-mail address is not valid.
10
The
focus()
method puts the cursor in the text box, so that the user can start typ-
ing there.
11
The
select()
method highlights the text in a field.
12
If
false
is returned to the
onSubmit
handler on line 15, the form will not be sub-
mitted.
13
If an invalid phone number was entered,
false
will be returned to the
onSubmit
handler on line 15.
14
If both the e-mail address and the phone number are valid, the
ok_Form()
func-
tion returns
true
to the event handler on line 15, and the form will be submitted
to the server's URL assigned to the form's
action
attribute.
15
The
onSubmit
event is triggered when the user clicks the submit button. The han-
dler is a function called
ok_Form()
. It is the main validation function for this form.
If
true
is returned, the form will be submitted; otherwise, not. See Figures 17.53,
17.54 and 17.55.
Figure 17.53
The user enters a valid e-mail address.