HTML and CSS Reference
In-Depth Information
Figure 17.50 The form before the user enters anything (left); the user enters a month and
year, but the month has already gone by (right).
Checking for Valid Type, Prefix, and Length. In Figure 17.51 the major credit
cards are listed along with the identifying characteristics of account numbers for each.
All the characters must be numbers. Each type of card has a prefix value; for example,
MasterCard's prefix is a number between 51 and 56, and Visa's is the number 4. Vali-
dation routines to check for a prefix and the correct number of characters are shown
in Example 17.47.
These are steps for credit card validation:
1. Remove any spaces or dashes, then test that the result is a numeric value.
2. Check to see if the user has selected a valid credit card type such as MasterCard
or Visa, the correct prefix for the card, and a valid length for the number of
characters in the card.
3. Apply the Lunh formula for further validation.
<head><title>Checking for Valid CC Type and Length</title>
<script type="text/javascript">
function checkCC(myForm){
var cc_type;
var cc_length;
if (myForm.select1.selectedIndex==0){
else if( myForm.select1.selectedIndex==1){
Search WWH ::

Custom Search