jquery custom credit card validation

Mark Steggles
Mark Steggles used Ask the Experts™
on
Hello,

I'm using jquery validate script and was using creditcard method. Now my client has obfuscated the credit card number if someone goes to edit their credit card info. Obfuscated with *****'s

So, I need a custom validation for jquery validate script to check for

credit card number or ***********'s + last 4 digits

Any ideas?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
why don't you simply do this
var str = "*3433";
var re = new RegExp("[\*]+[0-9]{4}", "g");
var myArray = re.test(str);
try this also
$('#creditCardNumber').valid8({
    'regularExpressions': [
        { expression: /^[\*]+[0-9]{4}$/, errormessage: 'Credit card number is not valid'}
    ]
});

download this package from here
http://www.unwrongest.com/projects/valid8/#

Commented:
You can use the this extra functionality for the full credit card number

http://www.ihwy.com/Labs/jquery-validate-credit-card-extension.aspx



Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Mark StegglesWeb Developer
Top Expert 2006

Author

Commented:
Thankyou Gurvinder32,

This [\*]+[0-9]{4} works on ***********4123

but it also needs to work for digits only 123123123123123123

what would be the update to make it work for that aswell?

Thanks
Mark StegglesWeb Developer
Top Expert 2006

Author

Commented:
solution was not complete
David S.Consultant & Challenge Subduer
Top Expert 2009

Commented:
This should allow either:

var re = /^(\*+|\d+)\d{4}$/;
Mark StegglesWeb Developer
Top Expert 2006

Author

Commented:
Thank you Kravimir, I will give that a whirl

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial