Here's a quick a dirty way to determine the card type automatically and show it to the user while they're typing.
That means
a) the user doesnt have to pick it and
b) they wont waste time looking for a dropdown that doesnt exist.
Very simple jQuery version for Amex, Visa and Mastercard.
if you need other card types you can take the
$('[id$=CreditCardNumber]').assertOne().keyup(function(){
// rules taken from http://en.wikipedia.org/wiki/Credit_card_number#cite_note-GenCardFeatures-0
var value = $(this).val();
$('#ccCardType').removeClass("unknown");
if ((/^4/).test(value)) {
$('#ccCardType').html("Visa");
return;
}
if ((/^5[1-5]/).test(value)) {
$('#ccCardType').html("Mastercard");
return;
}
if ((/^3[47]/).test(value)) {
$('#ccCardType').html("Mastercard");
return;
}
$('#ccCardType').html("Enter card number above");
$('#ccCardType').addClass("unknown");
});
This is the jQuery to accompany this (ASP.NET MVC):
Card number: <%= Html.TextBox("PaymentDetails.CreditCardDetails.CreditCardNumber")%>
Card Type: <span id="ccCardType" class="unknown">Enter card number above</span>
I have a css rule for .unknown
to display grayed out text.