My array of card types is structured like this:
var cards = new Array();
cards [0] = {name: "VISA", length: "13,16", prefixes: "4", checkdigit: true};
cards [1] = {name: "VISA_DELTA/ELECTRON", length: "16", prefixes: "417500,4917,4913", checkdigit: true};
I want to be able to identify the card type based on the entered credit card number. For instance, if a user selects "VISA" from a dropdown list, the card number should start with 4. If not, display a message asking the user to change the card type before submitting the form. Any assistance on this matter would be greatly appreciated.
The ID for the card number text field is CardNumber. I also have functions named Validate for form validation and Calculate for performing the Luhn check.