Open rolinger opened 2 years ago
For anyone interested:
onCreditCardTypeChanged: function (type) {
console.log(type) ;
switch(type) {
case 'amex' :
ccLength = [15] ;
cvcLength = 4 ;
break ;
case 'mastercard' :
ccLength = [16] ;
cvcLength = 3 ;
break ;
case 'visa' :
ccLength = [13,16] ;
cvcLength = 3 ;
break ;
case 'diners' :
ccLength = [14,15,16,17,18,19] ;
cvcLength = 4 ;
break ;
case 'discover' :
ccLength = [16] ;
cvcLength = 3 ;
break ;
case 'jcb' :
ccLength = [16] ;
cvcLength = 3 ;
break ;
case 'jcb' :
ccLength = [16] ;
cvcLength = 3 ;
break ;
case 'dankort' :
ccLength = [16] ;
cvcLength = 3 ;
break ;
case 'uatp' :
ccLength = [15] ;
cvcLength = 3 ;
break ;
case 'mir' :
ccLength = [16,19] ;
cvcLength = 3 ;
break ;
case 'unionpay' :
ccLength = [16,17,18,19] ;
cvcLength = 3 ;
break ;
}
}
4115680149517302486
thanks
When users add a CC number it instantly shows what type of card it is....but every type of card has its own required card number lengths and CVC lengths. Most cards CVCs are 3 digits, but Amex is 4. Most card lengths are 16, but some Visa's are 13 and Amex is 15.
Is there any method in cleave.js that can return the required card number lengths and the required CVC lengths?
I am doing form validation on a variety of fields, and prior to trying to use
cleave.js
my inputValidator strictly checked for cardNumberLength=16 (no spaces)) and cardCVCLength=3. But cleave.js inserts spaces into the card number taking a visa from 16 characters to 19....and an AMEX (which I wasn't testing for previously) is 15 characters, but with spaces would be 17 (or 18). So now my validator is causing problems when combined with cleave.js. Thus in order for both to cleanly to work, I need to be able to pass the card type lengths to my validator.As far as I can tell, cleave.js does not return those values.