Created
January 6, 2022 16:18
-
-
Save widnyana/52a9cb2e9a77824f1eb0b25b9dadc622 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkBankBin(cardNumber){ | |
var bankBinsSupport = ['970432','970416','9704163','970424','970418','970448','970426','970441','970403','970436','686868','970437','970429','550796','453618','970415','970443','970422','970454','970424']; | |
var result = new Object(); | |
result['support'] = false; | |
result['cardNumberFormat'] = '#### #### #### ####' | |
result['cardNumberLength'] = result['cardNumberFormat'].replace(/ /g,'').length; | |
if(cardNumber) { | |
cardNumber = cardNumber.replace(/ /g,''); | |
var l = Math.min(8, cardNumber.length); | |
for(var i = l; i > 3; i--) { | |
if(bankBinsSupport.indexOf(cardNumber.substring(0, i)) != -1) { | |
result.support = true; | |
break; | |
} | |
} | |
if(cardNumber.substring(0, 6) == '970436') { | |
result['cardNumberFormat'] = '######## ######## ###' | |
} | |
result['cardNumberLength'] = result['cardNumberFormat'].replace(/ /g,'').length; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment