A simple credit cards validation library in JavaScript.
You can download the zip file or use NPM and Bower.
$ npm install --save creditcard.js
$ bower install creditcard.js --save
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'
Name | Returns |
---|---|
CreditCard#isValid(cardNumber) |
Boolean |
CreditCard#isExpirationDateValid(month, year) |
Boolean |
CreditCard#isSecurityCodeValid(cardNumber, securityCode) |
Boolean |
CreditCard#getCreditCardNameByNumber(cardNumber) |
String |
Latest ✔ | Latest ✔ | 9+ ✔ | Latest ✔ | 8+ ✔ |
MIT © ContaAzul