Đang chuẩn bị liên kết để tải về tài liệu:
Học JavaScript qua ví dụ part 90

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Xác Nhận Thẻ tín dụng Khi chứng thực số thẻ tín dụng, bạn có thể làm một số kiểm tra sơ bộ nhưng có thật xác nhận thẻ được thực hiện trên server thông qua một sản phẩm phần mềm được thiết kế specifi-Cally cho mục đích đó | 17.5 Form Validation with Regular Expressions 783 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 message. The ok_Email function will return false and the form will not be submitted. 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. Checking for Valid Email Address Please enter your email address peterw@sun.com.se Send Clear 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 specifically for that purpose.4 Before issuing a card there are .