HTML and CSS Reference
In-Depth Information
EXPLANATION
1
A function called ok_Email is defined. It takes one parameter, a reference to the
form started on line 6.
2
This got the highest score at http://www.regexlib.com . When you are looking for
a regular expression that covers all possibilities, you might spend a week and
still not have caught everything. This is where the libraries come in handy.
Somebody has already done the hard work.
3
The regular expression test() method takes the value of the user input,
user_email.value , and returns true if the pattern in the regular expression matched
the user's input.
4
The e-mail address entered is tested to be valid. A true value is returned and the
form will be submitted to the server. A valid e-mail address does not mean that if
mail is sent to that address it will necessarily be delivered; for example, san-
ta@northpole.org is syntactically valid, but there is no guarantee that santa is a real
user (unless you still believe!).
5
If an invalid e-mail address was entered, the alert box will appear with this mes-
sage. The ok_Email() function will return false , and the form will not be submit-
ted.
6
The form named formtest starts here.
7
This is the URL of the CGI script that will be called on the server side when the
form is submitted.
8
The onSubmit event handler is triggered when the user clicks the submit button.
The value assigned to the event is a function called ok_Email that will return true
if the e-mail address is valid and false , if not. The form will be sent to the server
only if the return value is true . See Figure 17.49.
Figure 17.49 The user enters a valid e-mail address.
17.5.8 Credit Card Validation
When validating a credit card number, you can do some preliminary checking but real
card validation is done on the server side through a software product designed specifi-
cally for that purpose. 4 Before issuing a card, there are certain rules that must be fol-
lowed when creating card numbers, such as how many numbers there are, what prefix
 
 
Search WWH ::




Custom Search