Skip to content

A simple credit cards validation library in JavaScript. 💳

Notifications You must be signed in to change notification settings

vedovelli/creditcard.js

 
 

Repository files navigation

creditcard.js

Build Status Dependency Status devDependency Status

A simple library for credit-card validation in JavaScript

creditcard.js

Install

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

NPM

$ npm install --save-dev 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.getCreditCardNameByNumber('4539578763621486'); // returns 'Visa'

In the server:

var creditcard = require('creditcard.js');

var obj = new creditcard();
obj.getCreditCardNameByNumber('4539578763621486'); // returns 'Visa'

Methods

obj.validate()

Returns whether the value is true or false.

obj.validateExpirationDate()

Returns whether the value is true or false.

obj.validateSecuryCode()

Returns whether the value is true or false.

obj.getCreditCardNameByNumber()

Returns a String with the credit card name.

Browser support

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

License

MIT © Conta Azul

About

A simple credit cards validation library in JavaScript. 💳

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.3%
  • HTML 2.7%