top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to detect and validate credit card numbers in jQuery?

+2 votes
138 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 Google+ Share Button LinkedIn Share Button Multiple Social 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.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...