An easy to use, open-source (MIT license) library that provides interactive credit card input when making a purchase online. It is compatible with all modern browsers, is localizable, is based on pure CSS, and can be bolted on to most existing html forms in seconds. It currently supports VISA, MasterCard, and American Express out of the box, but it provides an easy way to extend the credit cards supported with a few lines of code.
If you like the library and have time, consider contributing to it! This library was made to improve the user checkout experience at Robert McNeel & Associates.
View a live demo here!
ajcc uses the latest CSS standards, and requires at least the following web browsers:
- Safari 5 or later.
- IE 10 or later.
- A recent version of Chrome, Firefox, or Opera.
- Other browsers adhering to the latest standards should also work.
If the browser is not supported, ajcc will automatically hide the credit card so it does not confuse the user. Also note that some of the latest browsers support even fancier CSS that will be automatically used to render a more realistic credit card.
This library requires jQuery to work. Just about any recent (1.5+, 2.0+) version will do.
##Getting started Follow the steps below and start clustering away in minutes!
-
Get the source code and images. Get the
ajcc.jsJavaScript file, theajcc.cssCSS file, and the default images for the credit card networks and the emv chip (visa.png,mastercard.png,amex.png, andchip.png). Put them somewhere convenient on your web server. -
Load the ajcc.js and ajcc.css in your page.
####### <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="/path/to/ajcc.js"></script>
- Create a new Card instance. To do so, we pass it a few jQuery objects: a container (such as a div tag) where the card will be displayed, and the input fields for the credit card in your form (you will need a field for the month and another field for the year). In addition, we pass it the credit card vendors we want to support, the URL for the
chip.pngimage, and an optional URL for a default icon to be displayed. ajcc has Visa, MasterCard, and American ExpressCardVendorobjects right out of the box for convenience. The credit card will be automatically displayed if the browser is compatible. That's all there is to it!
#######
var card = new ajcc.Card(
- Advanced: Make the most out of ajcc. Read the Reference to learn how to
- Create your own
CardVendorobjects to support additional credit card networks. - Get the current
CardVendorfor the user's credit card from theCardobject. - Force a redraw of the
Cardobject. - Check to see if the browser is compatible (so that perhaps you can display a different message when the credit card is displayed).
- Localize the rendered credit card fields for non-English environments.
- Create your own