HTML and CSS Reference
In-Depth Information
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.
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.
The alert dialog box sends this message if the e-mail address is not valid.
The focus() method puts the cursor in the text box, so that the user can start typ-
ing there.
The select() method highlights the text in a field.
If false is returned to the onSubmit handler on line 15, the form will not be sub-
If an invalid phone number was entered, false will be returned to the onSubmit
handler on line 15.
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.
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.
Search WWH ::

Custom Search