Link to home
Start Free TrialLog in
Avatar of saabStory
saabStoryFlag for United States of America

asked on

JQuery validation additional methods - Can't get creditcardtypes to validate numbers

Title says it all.  The regular creditcard:true method works fine but we don't process all the cards it checks, so I need to be able to restrict to Visa, MC, Amex and Discover - so I turned to the creditcardtypes method in the additionalMethods file and edited it to only check for those 4 cards.

But, it isn't validating anything - at least in the way I've edited it.  I know I'm doing something wrong but can't see what it is. I've created a test page with the issue and have attached it here.

As always, any help would be greatly appreciated.

test.php
Avatar of hankknight
hankknight
Flag of Canada image

SOLUTION
Avatar of hankknight
hankknight
Flag of Canada 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
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
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 saabStory

ASKER

You're right - I don't want to rely on Javascript solely for validity. In fact, that was one of my issues with the built in validation method - it only seems to check length - in addition to passing a lot of cards that we don't take.  I always use javascript for a quick check of each field before handing off to the server side code for a more extensive check using the plugin's remote method.

In this instance, I ended up bypassing the javascript check for this altogether and wrote my own server side check using regexes I found to check the card numbers and ranges I wanted.  It only checks length at the moment but will incorporate a luhn checker before the form is rolled out - I've just started looking for a library to use for that.

That said, I always rely on our Gateway provider for the final filter of everything.  I'm just trying to get everything as correct as possible before I send to the gateway.