top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to detect and validate credit card numbers in jQuery?

+2 votes
721 views
How to detect and validate credit card numbers in jQuery?
posted Jun 2, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Query Credit Card Validator is written in CoffeeScript and (surprise, surprise!) is a jQuery plugin. It analyses the card number in the input field on which it was called, and returns an object with four properties:

card_type — an object with the below properties, or null if card type unknown
name — one of the strings describing the card type, eg visa
pattern — regular expression used to match the card type, eg /^4/
length — a list of valid lengths for the card type, eg [13, 16]
valid — true if the number is valid, false otherwise
length_valid — true if the number length is valid, false otherwise
luhn_valid — true if the Luhn checksum is correct, false otherwise

answer Jun 13, 2015 by Vrije Mani Upadhyay
Similar Questions
+3 votes

I am trying to control input field using jQuery previously I had only numbers and could use $(this).autoNumeric(), now I have come around where it is required to change the input field in form of 'Numbers dash Numbers'.
i.e:- 1.343-45.643

Is there anything similar to autoNumeric which can do my work apart from writing my own regex and jquery method.

0 votes

Please give the example for both.

...