Card lets you add an interactive, CSS3 credit card animation to your credit card form to help your users through the process.
!npm
/dist/card.js and include it in your HTML like so.
html
`
Once you've included those files, you can initialize Card.
`javascript
var card = new Card({
// a selector or DOM element for the form where users will
// be entering their information
form: 'form', // required
// a selector or DOM element for the container
// where you want the card to appear
container: '.card-wrapper', // required
formSelectors: {
numberInput: 'input#number', // optional — default input[name="number"]
expiryInput: 'input#expiry', // optional — default input[name="expiry"]
cvcInput: 'input#cvc', // optional — default input[name="cvc"]
nameInput: 'input#name' // optional - defaults input[name="name"]
},
width: 200, // optional — default 350px
formatting: true, // optional - default true
// Strings for translation - optional
messages: {
validDate: 'valid\ndate', // optional - default 'valid\nthru'
monthYear: 'mm/yyyy', // optional - default 'month/year'
},
// Default placeholders for rendered fields - optional
placeholders: {
number: '•••• •••• •••• ••••',
name: 'Full Name',
expiry: '••/••',
cvc: '•••'
},
masks: {
cardNumber: '•' // optional - mask card number
},
// if true, will log helpful messages for setting up Card
debug: false // optional - default false
});
`
$3
If you're using bower, you can install card.js with:
bower install card --save
$3
If you're using npm, you can install card.js with:
npm install --save card
var $ = require("jquery");
// The current card.js code does not explictly require jQuery, but instead uses the global, so this line is needed.
window.jQuery = $;
var card = require("card");
$3
Card can be used in forms where you have multiple inputs that render to a single field (i.e. you have a first and last name input). To use Card with this functionality, just pass in a selector that selects the fields in the correct order. For example,
`html
`
$3
Card renders with default placeholders for card name, number, expiry, and cvc. To override these placeholders, you can pass in a placeholders object.
`html
`
$3
To render the card with the strings in a different language, you can pass in a messages object.
`html
`
Using with jQuery
To use with jQuery, you'll need to include the jquery.card.js file into your HTML. You can find the necessary file at /dist/jquery.card.js and include it in your HTML like so.
`html
`
Once you've included those files, you can initialize Card with jQuery.
`javascript
$('form').card({
// a selector or DOM element for the container
// where you want the card to appear
container: '.card-wrapper', // required
// all of the other options from above
});
`
Using with other javascript libraries
Card has wrappers that make it easy to use with other javascript libraries:
$3
* angular-card
$3
* ngx-card
$3
* ember-credit-card
$3
* react-credit-card
* card-react
* react-plastic - static CSS only version.
$3
For use with VueJs, install card.js from npm:
`bash
npm install card --save
`
Add in your component an Div with class 'card-wrapper', just pass in a selector that selects the fields in the correct order. Import the component card.js and add the object in instance mounted like this example:
`html
`
Development
To contribute, follow this steps:
`bash
$ git clone --recursive https://github.com/jessepollak/card.git
$ cd card
$ git submodule init && git submodule update
$ npm install
$ npm run development
`
Now, if you go to localhost:8080/example in your browser, you should see the demo page.
Places using Card
Card is used in the wild in these places:
* InspectAll
* PennyWhale
* MakeSpace
* Blumpa
* CourseLoads
* PubNub
* GigSalad
* Boligninja
* EasyCarros
* Sintelle
* Wevorce
* PayumServer
* Paribus
* Bizzabo
* Tortuba
* Netlify
* The Spice House
* Touts
* Ryman Limited
* Robert Dyas
* ROKA
* LeSalon
* Kenyan Directorate Of Immigration And Citizen Service
Are you using Card in production? If so, we'd love to link to you from this page. Open a PR or drop @jessepollak a line on Twitter and we'll add you right away!
Project scope
The project scope is to improve the capture of payment cards on websites. Issues and fixes related to the user interface and validating of payment cards are in scope.
For questions on how to use Card in your particular project, please ask on Stack Overflow or similar forum.
Donations
If you'd like to donate to help support development of Card, send Bitcoin directly to 17NUKd3v7GWben18kGhmFafa4ZpWrXpQSC` or through Coinbase here.