Link to home
Start Free TrialLog in
Avatar of kw66722
kw66722

asked on

Checking Credit Card number is valid

I need to check whether is credit card number is a valid format for the type of credit card that is giving to me. I am passing the number to other place that will do the actual check.  I had found this
for each card when I tested with actual number for the particular type for card I got errors. Am I missing something in the regular expression?

This is be coded in VBNET on the back end.

  Case "AX"
                    RegEx = New System.Text.RegularExpressions.Regex("3[4,7]\d{13}")
                Case "DS"
                    RegEx = New System.Text.RegularExpressions.Regex("6011-?\d{4}-?\d{4}-?\d{4}")
                Case "MC"
                    RegEx = New System.Text.RegularExpressions.Regex("5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}")
                Case "VA"
                    RegEx = New System.Text.RegularExpressions.Regex("4\d{3}-?\d{4}-?\d{4}-?\d{4}")


           
ASKER CERTIFIED SOLUTION
Avatar of binaryevo
binaryevo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kw66722
kw66722

ASKER

worked like a charm thanks.