Skip to content

leandroasilva/creditcard.js

 
 

Repository files navigation

creditcard.js

Build Status Dependency Status devDependency Status

A simple credit cards validation library in JavaScript.

creditcard.js

Install

You can download the zip file or use NPM and Bower.

NPM

$ npm install --save creditcard.js

Bower

$ bower install creditcard.js --save

Usage

In the browser:

<script type="text/javascript" src="dist/creditcard.min.js"></script>
var obj = new CreditCard();
obj.isValid('4916108926268679'); // returns true
obj.isExpirationDateValid('02', '2020'); // returns true
obj.isSecurityCodeValid('4556603578296676', '250'); // returns true
obj.getCreditCardNameByNumber('4539578763621486'); // returns 'Visa'

In the server:

var creditcard = require('creditcard.js');
var obj = new creditcard();
obj.isValid('4916108926268679'); // returns true
obj.isExpirationDateValid('02', '2020'); // returns true
obj.isSecurityCodeValid('4556603578296676', '250'); // returns true
obj.getCreditCardNameByNumber('4539578763621486'); // returns 'Visa'

Functions

Name Returns
CreditCard#isValid(cardNumber) Boolean
CreditCard#isExpirationDateValid(mouth, year) Boolean
CreditCard#isSecurityCodeValid(cardNumber, securityCode) Boolean
CreditCard#getCreditCardNameByNumber(cardNumber) String

Browser support

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
Latest ✔ Latest ✔ 9+ ✔ Latest ✔ 8+ ✔

License

MIT © ContaAzul

About

A simple credit cards validation library in JavaScript. 💳

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.5%
  • HTML 2.5%