Author: | ContaAzul |
---|---|
Views Total: | 13 views |
Official Page: | Go to website |
Last Update: | February 26, 2021 |
License: | MIT |
Preview:

Description:
credicard.js is a zero-dependency JavaScript library for validating credit card number, expiration date, security code and returning the credit card brand.
Supports both browser and server.
Supported Credit Card Types:
- American Express
- Aura
- Banescard
- Cabal
- Diners
- Discover
- Elo
- Goodcard
- Hipercard
- Mastercard
- Maxxvan
- Visa
How to use it:
Install & import the credicard.js component.
# NPM $ npm i creditcard.js
import { isValid, isExpirationDateValid, isSecurityCodeValid, getCreditCardNameByNumber } from 'creditcard.js';
Or include the credicard.js script on your webpage.
<script src="creditcard.js"></script>
Validate a specified credit card number.
var creditcard = new CreditCard(); // return true console.log(creditcard.isValid('4111111111111111')); isValid('4916108926268679', { cards: ['visa', 'mastercard'] }) // returns true isValid('4916108926268679', { cards: ['mastercard'] }) // returns false
Validate the expiration date.
var creditcard = new CreditCard(); // return true console.log(creditcard.isExpirationDateValid(''05', '2020''));
Validate the security code.
var creditcard = new CreditCard(); // return true console.log(creditcard.isSecurityCodeValid(''4111111111111111', '250''));
Validate a specified credit card number and return the result in the console.log.
var creditcard = new CreditCard(); // return 'Visa' console.log(creditcard.getCreditCardNameByNumber('4111111111111111'));
Changelog:
v3.0.5 (02/26/2021)
- IsValid card options
v3.0.3 (01/21/2021)
- Bug Fixes
v3.0.0 (01/18/2021)
- v3
v2.1.5 (05/25/2018)
- Update CREDIT_CARD_LIST to use literal regex