Bin e padrões para validação de cartão de crédito.
| Bandeira | Começa com | Máximo de número | Máximo de número cvc |
|---|---|---|---|
| Visa | 4 | 13,16 | 3 |
| Mastercard | 5 | 16 | 3 |
| // Takes a credit card string value and returns true on valid number | |
| function valid_credit_card(value) { | |
| // Accept only digits, dashes or spaces | |
| if (/[^0-9-\s]+/.test(value)) return false; | |
| // The Luhn Algorithm. It's so pretty. | |
| let nCheck = 0, bEven = false; | |
| value = value.replace(/\D/g, ""); | |
| for (var n = value.length - 1; n >= 0; n--) { |