Link to home
Start Free TrialLog in
Avatar of usnow2
usnow2

asked on

Client-side validation of credit cards in Virtuemart

I am trying to write some code that will validate the information for processing a credit card payment in Virtuemart.

At the very least I want to validate or prevent the following:
- Entering an expiration date older than today.
- A security code containing more than three digits or characters.

Any ideas or pointers will be welcome.

Thanks
Avatar of Member_5340450
Member_5340450

So you don't want to wait for server validation, you're trying to catch it on client side?
Avatar of usnow2

ASKER

Yes, I want to prevent displaying useless information to the user and forcing them to go back in the checkout process and fixing the information previously entered.  Virtuemarts' server-side validation will thus only take place if the client-side validation succeeds and the form is submitted.
This might be less than you're looking for but an actual answer would take a pretty long time to write.

Scripts to do the validation:
http://www.google.com/search?q=javascript+validate+credit+card+form&sourceid=ie7&rls=com.microsoft:en-us:IE-Address&ie=&oe=

Where to add the code:
components/com_virtuemart/themes/default/templates/checkout/list_payment_methods.tpl.php line 24
Avatar of usnow2

ASKER

Thanks, I of course didn't mean that you have to generate all the code :)

The file reference you mention above however is one part of the puzzle.  I'm also looking for the file where the form is being opened.  Do you know in which file the opening form tag for this form will be located?
I'm pretty sure it's
      components/com_virtuemart/html/checkout_index.php line 271
appears to be a javascript submit being tagged on at line 354.
Avatar of usnow2

ASKER

I'll check to see if I can get a solution working a bit later, just wanted to mention that the file above should be: ADMINSTRATOR/components/com_virtuemart/html/checkout_index.php
ASKER CERTIFIED SOLUTION
Avatar of Member_5340450
Member_5340450

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 usnow2

ASKER

Thanks, those were the pages in which I was able to add my custom validation code.