creditCard validator

Validate a credit card number


Using with form field

The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
message data-fv-credit-card___message String The error message

Behind the scene, in addition to using the Luhn algorithm, the validator also validate the IIN ranges and length of credit card number.

It supports validating the following cards:

Type Sample Is it valid?
American Express 340653705597107
Dankort 5019717010103742
Diners Club 30130708434187
Diners Club (US) 5517479515603901
Discover 6011734674929094
Elo 6362970000457013
JCB 3566002020360505
Laser 6304 9000 1774 0292 441
Maestro 6762835098779303
Mastercard 5303765013600904
Solo 6334580500000000
Visa 4929248980295542
Visa Electron 4917300800000000


13 digits Visa credit cards are no longer used and it will be treated as an invalid card number

Using with ES6 module


You can use to generate fake credit card numbers

Basic Example

ES6 Module Example

The following snippet shows how to use the creditCard validator with ES6 module:

More examples

Related validators

The following validators might be useful to you.