Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Credit Card Validator

This project is a pure JavaScript implementation that offers credit card validation support. It is written modular such that one could bundle only the components that are required. So for instance the smallest footprint in its minimized form could be 1K. No external JS|PHP framework or module bundler is required at all.

The JavaScript implementation is splitted in few tiny modules (which can be bundled together). It answers the following questions:

  • if the credit card and/or CCV are syntactically valid (they match the issuer numbering pattern)
  • if the card expiry date is valid (basically it parses the string and compares it against the current date)
  • gives the credit card issuer name (American Express, Visa, MasterCard, Discover, DinersClub, JCB and Maestro only)

Furthermore the library contains some extended functionalities that aids in:

  • check the validity of a postal code length given the country code (handy if your checkout card form includes a Postal Code field)
  • check if a given country has Braintree Payment Gateway support (given the Braintree module one could easily create similar modules for Stripe, PayPal, etc)

What this repo includes

  • src directory contains the source code of the library (a tiny monolithic module)
  • src/deps directory contains other dependent JS modules that, with the exception of Utils and Constants, could be just discarded and still get a credit card validator library (without extended functionality)
  • dist directory contains a unminified and a minified bundle of the library (together with the bundle builder script)
  • demo directory contains a demo application (index.html,bundle.min.js,app.css,cc-badge.png)

Online Sandbox


Pure JavaScript|PHP class that aids in credit card validation







No releases published


No packages published