NEFA | Premium Free Business Website Template Built with Vue.js
Download NEFA, a free, high-performance business website template built with Vue.js, Nuxt.js, and Tailwind CSS. Fully responsive, SEO-friendly, and ea…
CardJs is a jQuery plugin that allows you to create a full-featured credit card form for your e-commerce website or online store to provide a seamless checkout experience.
In your HTML document, include the jQuery library and the CardJs jQuery plugin files.
Simply add the class card-js to the credit card form container, and the plugin will handle the rest.
Determine whether to capture the card name.
Change the icon colors.
Get credit card form values
var myCard = $('#devstocDemo');
var cardNumber = myCard.CardJs('cardNumber');
var cardType = myCard.CardJs('cardType');
var name = myCard.CardJs('cardHolderName');
var expiryMonth = myCard.CardJs('expiryMonth');
var expiryYear = myCard.CardJs('expiryYear');
var cvc = myCard.CardJs('cvcNumber');
Detect the card type by the entered card number.
CardJs.cardTypeFromNumber(cardNumber);
Input Mask card numbers.
| Variable Name | Mask Pattern |
|---|---|
| CardJs.CREDIT_CARD_NUMBER_DEFAULT_MASK | XXXX XXXX XXXX XXXX |
| CardJs.CREDIT_CARD_NUMBER_VISA_MASK | XXXX XXXX XXXX XXXX |
| CardJs.CREDIT_CARD_NUMBER_MASTERCARD_MASK | XXXX XXXX XXXX XXXX |
| CardJs.CREDIT_CARD_NUMBER_DISCOVER_MASK | XXXX XXXX XXXX XXXX |
| CardJs.CREDIT_CARD_NUMBER_JCB_MASK | XXXX XXXX XXXX XXXX |
| CardJs.CREDIT_CARD_NUMBER_AMEX_MASK | XXXX XXXXXX XXXXX |
| CardJs.CREDIT_CARD_NUMBER_DINERS_MASK | XXXX XXXX XXXX XX |
// var formatMask = 'XXXX XXXX XXXX XXXX'; // You can manually define an input mask // var formatMask = 'XX+X X XXXX XXXX XXXX'; // You can add characters other than spaces to the mask var formatMask = CardJs.CREDIT_CARD_NUMBER_VISA_MASK; // Or use a standard mask. var cardNumber = '424 2424242 42 42 42'; var cardNumberWithoutSpaces = CardJs.numbersOnlyString(cardNumber); var formattedCardNumber = CardJs.applyFormatMask(cardNumberWithoutSpaces, formatMask);
Validate Credit card expiration date.
var month = "3"; var year = "19"; var valid = CardJs.isExpiryValid(month, year);
Visit the official Documentation page to learn more about CardJs features.