This repository was archived by the owner on Aug 26, 2025. It is now read-only.
forked from stripe-archive/jquery.payment
-
Notifications
You must be signed in to change notification settings - Fork 103
Credit Card Number
Omar Shammas edited this page Sep 13, 2013
·
2 revisions
Formats the credit card card number:
- Limits to 16 numbers
- Restricts input to numbers
- Includes a space between every 4 digits
- American Express formatting support
- Adds a class of the card type (i.e. 'visa') to the input
$('input.credit_card_number').formance('format_credit_card_number');Validates the credit card number:
- Validates numbers
- Validates Luhn algorithm
- Validates length
$('input.credit_card_expiry').formance('validate_credit_card_number');
//examples
$("<input value='4242424242424242' />").formance('validate_credit_card_number'); // true
$("<input value='4242 4242 4242 4242' />").formance('validate_credit_card_number'); // true
$("<input value='4242-4242-4242-4242' />").formance('validate_credit_card_number'); // true
$("<input value='4242' />").formance('validate_credit_card_number'); // falseThis field includes a special helper function to retrieve the credit card type. It recognizes
visamastercarddiscoveramexdinersclubmaestrolaserunionpay
The function will return null if the card type can't be determined.
$.formance.creditCardType('4242 4242 4242 4242') // 'visa'Make sure to read about the credit card autocomplete recommendations.