Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Credit Card Validation

    I was wondering if credit card validation was done by communication with a card company, or if it could be done with a script. This would be implemented on a secure server, of course. If it can be done with a script, can someone tell me how to get started?

    Peter

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Best off using a third party when involving credit cards. Use something like www.paysystems.com

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This works for me. It will validate whether or not the Credit Card Number is a possible credit card number. There are certain mathmatical rules (which I will not get into now, [because I don't know them]) which determine possible valid numbers.

    This has always worked for me.

    Code:
    function isValidCC(n) {
      re = /^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$/
      return = re.test(n);
    }
    
    Usage:
    if (isValidCC("1234569878956454")) {
       alert("YAY, it is valid");
    } else {
       alert("Blast, it is invalid!");
    }
    For Seeeecret Eating


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •