Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.


Javascript To Prevent Problem With Credit Card Orders

Recommended Posts

I have a regularly occuring problem becuase I also provide: 1) an option for customers to mail payment and 2) another for them to fax their credit card payment. Unfortunately, some cutomers type in their CC information and then click the wrong payment radio button. Thus, they think they have paid for thier order with a credit card when in fact they have not. When we contact them, they think we are cheating them because they are certain they entered their CC as payment.


To solve this problem, I want to add a JS to the payment page that will set the CC radio button automatically if there is anything typed in the CC field.


I hope someone can help since I am not good with JavaScript.... especially on a PHP site.



Thanks for any advice!



Anthony David


Share this post

Link to post
Share on other sites

Amazingly, seven years later, I am back to this same challenge as we upgrade our site to OSC v2.3.  To solve the original problem posted in 2007, I had a friend graciously help me with writing some JavaScript that we utilized for several years.  Upon implementing that JS, all of the issues described within the original post, simply stopped.  It was beautiful!!!  
Unfortunately, the JS was not flexible enough to handle the addition and/or removal of payment modules.  Now, V2.3 payment options are a bit different and we have also changed which Merchant Services/Gateway.  Thus, we are back trying to find a resolution to this issue.  I did find a similar post to this but it seems to have challenges of its own.
Perhaps, I just haven't found the right post and someone has already described a solution that will...

  • Default the payment option to "Credit Card" rather than one of less desired and less frequently utilized options.
  • Set the CC radio button if any CC details are entered.
  • Prevent the customer from changing radio buttons until they delete all CC details?

Below is the script we used for several years.  But for some reason, it now only works once on the page.  It will identify if the user has input characters within the credit card number field while also selecting an alternative payment method.   However, it only does the check a single time rather than continuing to monitor their actions.
Perhaps someone with the right skills can improve upon it for all of us.


  echo "checkCreditCardNumber();";
  echo "function checkCreditCardNumber(){
      if(document.checkout_payment.authorizenet_aim_cc_number.value!=''  && (!document.checkout_payment.payment[1].checked  && !document.checkout_payment.payment[2].checked && !document.checkout_payment.payment[3].checked)){

      if( (document.checkout_payment.payment[1].checked || document.checkout_payment.payment[2].checked  ||
      document.checkout_payment.payment[3].checked) && document.checkout_payment.authorizenet_aim_cc_number.value!=''  ){

          alert('You have chosen to change payment type while also entering credit card number information.  If you prefer to use a payment method other than credit card, please first delete the credit card number you have entered.');
          return false;        


  echo "</script>";

Anthony David


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now