Payment

A jQuery-free general purpose library for building credit card forms, validating inputs and formatting numbers. Heavily, heavily based on @stripe's jquery.payment library, but without the jQuery.
For example, you can make a input act like a credit card field (with number formatting and length restriction):
Payment.formatCardNumber(document.querySelector('input.cc-num'));
Then, when the payment form is submitted, you can validate the card number on the client-side:
var valid = Payment.fns.validateCardNumber(document.querySelector('input.cc-num').value);
if (!valid) {
alert('Your card is not valid!');
return false;
}
You can find a full demo here.
Supported card types are:
- Visa
- MasterCard
- American Express
- Discover