javascript Get Credit Card Type By Number (regex validation example)
@May 21, 2009, 5:05 a.m.
document.write('3400 0000 0000 009=' + GetCreditCardTypeByNumber('3400 0000 0000 009'));
document.write('6011 0000 0000 0004=' + GetCreditCardTypeByNumber('6011 0000 0000 0004'));
document.write('5500 0000 0000 0004=' + GetCreditCardTypeByNumber('5500 0000 0000 0004'));
document.write('4111 1111 1111 1111=' + GetCreditCardTypeByNumber('4111 1111 1111 1111'));
function GetCreditCardTypeByNumber(ccnumber) {
var cc = (ccnumber + '').replace(/\s/g, ''); //remove space
if ((/^(34|37)/).test(cc) && cc.length == 15) {
return 'AMEX'; //AMEX begins with 34 or 37, and length is 15.
} else if ((/^(51|52|53|54|55)/).test(cc) && cc.length == 16) {
return 'MasterCard'; //MasterCard beigins with 51-55, and length is 16.
} else if ((/^(4)/).test(cc) && (cc.length == 13 || cc.length == 16)) {
return 'Visa'; //VISA begins with 4, and length is 13 or 16.
} else if ((/^(300|301|302|303|304|305|36|38)/).test(cc) && cc.length == 14) {
return 'DinersClub'; //Diners Club begins with 300-305 or 36 or 38, and length is 14.
} else if ((/^(2014|2149)/).test(cc) && cc.length == 15) {
return 'enRoute'; //enRoute begins with 2014 or 2149, and length is 15.
} else if ((/^(6011)/).test(cc) && cc.length == 16) {
return 'Discover'; //Discover begins with 6011, and length is 16.
} else if ((/^(3)/).test(cc) && cc.length == 16) {
return 'JCB'; //JCB begins with 3, and length is 16.
} else if ((/^(2131|1800)/).test(cc) && cc.length == 15) {
return 'JCB'; //JCB begins with 2131 or 1800, and length is 15.
}
return '?'; //unknow type
}
function IsValidCC(str) { //A boolean version
if (GetCreditCardTypeByNumber(str) == '?') return false;
return true;
}
document.write('6011 0000 0000 0004=' + GetCreditCardTypeByNumber('6011 0000 0000 0004'));
document.write('5500 0000 0000 0004=' + GetCreditCardTypeByNumber('5500 0000 0000 0004'));
document.write('4111 1111 1111 1111=' + GetCreditCardTypeByNumber('4111 1111 1111 1111'));
function GetCreditCardTypeByNumber(ccnumber) {
var cc = (ccnumber + '').replace(/\s/g, ''); //remove space
if ((/^(34|37)/).test(cc) && cc.length == 15) {
return 'AMEX'; //AMEX begins with 34 or 37, and length is 15.
} else if ((/^(51|52|53|54|55)/).test(cc) && cc.length == 16) {
return 'MasterCard'; //MasterCard beigins with 51-55, and length is 16.
} else if ((/^(4)/).test(cc) && (cc.length == 13 || cc.length == 16)) {
return 'Visa'; //VISA begins with 4, and length is 13 or 16.
} else if ((/^(300|301|302|303|304|305|36|38)/).test(cc) && cc.length == 14) {
return 'DinersClub'; //Diners Club begins with 300-305 or 36 or 38, and length is 14.
} else if ((/^(2014|2149)/).test(cc) && cc.length == 15) {
return 'enRoute'; //enRoute begins with 2014 or 2149, and length is 15.
} else if ((/^(6011)/).test(cc) && cc.length == 16) {
return 'Discover'; //Discover begins with 6011, and length is 16.
} else if ((/^(3)/).test(cc) && cc.length == 16) {
return 'JCB'; //JCB begins with 3, and length is 16.
} else if ((/^(2131|1800)/).test(cc) && cc.length == 15) {
return 'JCB'; //JCB begins with 2131 or 1800, and length is 15.
}
return '?'; //unknow type
}
function IsValidCC(str) { //A boolean version
if (GetCreditCardTypeByNumber(str) == '?') return false;
return true;
}
Permanent URL:
http://javascript.gakaa.com/credit-card-type-by-number.aspx
Looking for a trusted online gambling experience? You're not alone — thousands of players every day choose platforms that combine entertainment and fair play in one place. Whether you’re into sports betting, there’s always a right option — especially when everything is designed to be transparent.
One such place is a complete online gaming platform where players get access to top-rated games and regular promotions. That’s what makes the experience not only enjoyable, but also responsible.
The platform offers everything from bonus-packed slots to progressive jackpots. Whether you prefer trying new mechanics, there’s something tailored to your style.
For example, players can explore top titles like Wolf Gold, or jump into exclusive categories such as baccarat games. On the other hand, those who love arcade speed often go for games like Crash Royale.
And for sports lovers, the site covers everything from golf and esports to niche markets with live betting options and custom bet slips. Even new players can access exclusive promo codes from day one, making it easy to boost the first bet.
The navigation is simple, the support team is available 24/7, and the registration process takes just a few moments. Plus, players can switch between desktop and mobile versions seamlessly — or download dedicated apps for both smartphones and tablets.
And most importantly — everything is legal, secure, and built around fair gaming practices. The project holds transparent terms, and provides tools for responsible gaming, giving users full control over their experience.
Discover more by visiting one of the platform’s pages:
https://pinupcasinopinup.ca/basketball-betting/
No matter what kind of experience you’re seeking — competitive betting — you’ll find it here. With constant updates, new releases, and a friendly community, it’s easy to stay engaged, try new things, and enjoy every minute of play.
Try it now and see why this platform remains a favorite choice among players from all over.
One such place is a complete online gaming platform where players get access to top-rated games and regular promotions. That’s what makes the experience not only enjoyable, but also responsible.
The platform offers everything from bonus-packed slots to progressive jackpots. Whether you prefer trying new mechanics, there’s something tailored to your style.
For example, players can explore top titles like Wolf Gold, or jump into exclusive categories such as baccarat games. On the other hand, those who love arcade speed often go for games like Crash Royale.
And for sports lovers, the site covers everything from golf and esports to niche markets with live betting options and custom bet slips. Even new players can access exclusive promo codes from day one, making it easy to boost the first bet.
The navigation is simple, the support team is available 24/7, and the registration process takes just a few moments. Plus, players can switch between desktop and mobile versions seamlessly — or download dedicated apps for both smartphones and tablets.
And most importantly — everything is legal, secure, and built around fair gaming practices. The project holds transparent terms, and provides tools for responsible gaming, giving users full control over their experience.
Discover more by visiting one of the platform’s pages:
https://pinupcasinopinup.ca/basketball-betting/
No matter what kind of experience you’re seeking — competitive betting — you’ll find it here. With constant updates, new releases, and a friendly community, it’s easy to stay engaged, try new things, and enjoy every minute of play.
Try it now and see why this platform remains a favorite choice among players from all over.
Pin up casino Canada
- 57 hours
Hello. And Bye.
Brianwaymn
- 67 hours
Powered by Linode.
</a>