in Resources

jQuery Credit Card Validator Plugin

Does your website take credit card payments? If so then you will need to validate the credit card number to make sure that it has the correct characters in the input box before it is sent to the server for the check. Doing these sort of checks on the client side will make sure that you aren't sending people to your server just to validate a wrong number on their credit card. Here is jQuery plugin which will validate the input of the credit card numbers, tell you what type of credit card it is and if the length of numbers are correct for the type of card. jQuery Credit Card Validator — Pawel Decowski

Supported Credit Cards

  • American Express — amex
  • Diners Club Carte Blanche — diners_club_carte_blanche
  • Diners Club International — diners_club_international
  • Diners Club United States & Canada — mastercard (it is actually a MasterCard)
  • Discover Card — discover
  • JCB — jcb
  • Laser — laser
  • Maestro — maestro
  • MasterCard — mastercard
  • Visa — visa
  • Visa Electron — visa_electron

The plugin will check the numbers on your input field and will send it to your own defined function where you can see 3 properties to see if the card is valid. The parameters which you can use are: - Card Type

  • Pattern
  • Length

Here is a quick example of how it is used inside a function.

    alert('Credit Card type: ' + result.card_type
      + '\nLength validation: ' + result.length_valid
      + '\nLuhn validation: + result.luhn_valid');

It's that simple to validate credit cards on the client side with this jQuery plugin. Download From Github