Press "Enter" to skip to content

A Simple Credit Cards Validation Library in JavaScript | creditcard.js

credicard.js is a JavaScript library with no dependency for validating credit card numbers, expiration dates, security code, and credit card branding.

It supports both browser and server.

Supported credit card types

  • American Express
  • Aura
  • Banescard
  • Cabal
  • Diners
  • Discover
  • Elo
  • Good card
  • Hipercard
  • Mastercard
  • Maxxvan
  • Visa

How to make use of it:

Install & import the credicard.js element.

# NPM
$ npm i creditcard.js
import { 
  isValid, 
  isExpirationDateValid, 
  isSecurityCodeValid, 
  getCreditCardNameByNumber 
} from '

Or embody the credicard.js script in your webpage.

<script src="creditcard.js"></script>

Validate a specified credit card quantity.

var creditcard = new CreditCard();
// return true
console.log(creditcard.isValid('4111111111111111'));

Validate the expiration date.

var creditcard = new CreditCard();
// return true
console.log(creditcard.isExpirationDateValid(''05', '2020''));

Validate the safety code.

var creditcard = new CreditCard();
// return true
console.log(creditcard.isSecurityCodeValid(''4111111111111111', '250''));

Validate a specified credit card quantity and return the end result within the console.log.

var creditcard = new CreditCard();
// return 'Visa'
console.log(creditcard.getCreditCardNameByNumber('4111111111111111'));

Validating Credit Card Numbers, creditcard JS Plugin/Github


See Demo And Download

Official Website(ContaAzul): Click Here

This superior jQuery/javascript plugin is developed by ContaAzul. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *