Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ccregex
if (cardNumberValue.match(/^((?:222\d{1})\d{12}|(?:22[3-9])\d{13}|(?:2[3-6])\d{14}|(?:27[1])\d{13}|(?:2720)\d{12}|(?:5[1-5])\d{14})$/)) {
return mastercardAccepted;
} else if(cardNumberValue.match(/^4(\d{12}|\d{15})$/)) {
return visaAccepted;
} else if(cardNumberValue.match(/^(?:3[47])\d{13}$/)) {
return amexAccepted;
} else if(cardNumberValue.match(/^((?:65)\d{12}|(?:64[4-9])\d{11}|(?:6011)\d{10})$/)) {
return discoverAccepted;
} else if(cardNumberValue.match(/^(?:352[8-9])\d{11,12}|(?:35[3-8])\d{12,13}|(?:2131)\d{11}|(?:1800)\d{11}$/)) {
return jcbAccepted;
} else if(cardNumberValue.match(/^((?:30[0-5])\d{11}|(?:3[68])\d{12})$/)) {
return dinersclubAccepted;
} else if(cardNumberValue.match(/^((?:50[023456789]|62[179]|67[0-7]|60[2-5]|679)\d{9,16}|(?:501[0-8]|601[023456789]|676[0-9]|6771|6060|6304|6390)\d{8,15}|(?:5[6-9])\d{10,17})$/)) {
return maestroAccepted;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment