Credit Card Validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant

    Credit Card Validation





    Does any one know how to check the algorithm of the credit card number that
    was entered in the text box? I want to be able to make sure the users enter
    correct credit card number since we will process it manually via phone. I
    want this to be done on the server side behind the code in ASP.Net. Thanks


  • vMike

    #2
    Re: Credit Card Validation

    Take a look at this site.



    "Grant" <Grant@nutrikid s.com> wrote in message
    news:u$vJ8X6SDH A.3132@tk2msftn gp13.phx.gbl...[color=blue]
    >
    >
    >
    >
    > Does any one know how to check the algorithm of the credit card number[/color]
    that[color=blue]
    > was entered in the text box? I want to be able to make sure the users[/color]
    enter[color=blue]
    > correct credit card number since we will process it manually via phone. I
    > want this to be done on the server side behind the code in ASP.Net. Thanks
    >
    >[/color]


    Comment

    • S. Justin Gengo

      #3
      Re: Credit Card Validation

      I have a credit card validation sample on my web site in the code library:


      It's titled: Regular expression credit card validation. I haven't
      implemented a way to search the database yet, but if you set the first drop
      down list to: Web or Windows, and the second drop down to: JavaScript it
      will limit the library to just that entry.

      --
      S. Justin Gengo
      Web Developer / Programmer

      Free Code Library At:


      "Out of chaos comes order."
      Nietzche


      "Grant" <Grant@nutrikid s.com> wrote in message
      news:u$vJ8X6SDH A.3132@tk2msftn gp13.phx.gbl...[color=blue]
      >
      >
      >
      >
      > Does any one know how to check the algorithm of the credit card number[/color]
      that[color=blue]
      > was entered in the text box? I want to be able to make sure the users[/color]
      enter[color=blue]
      > correct credit card number since we will process it manually via phone. I
      > want this to be done on the server side behind the code in ASP.Net. Thanks
      >
      >[/color]


      Comment

      • vMike

        #4
        Re: Credit Card Validation

        Here is an access function for generic card testing which might help you
        also.

        Function CreditCardCheck Digit(strCredit Card As String) As Boolean
        Dim intLength As Integer
        Dim intEvenSum As Integer
        Dim intOddSum As Integer
        Dim i As Integer
        CreditCardCheck Digit = False
        On Error GoTo Errorhandler
        intEvenSum = 0
        intOddSum = 0
        intLength = Len(strCreditCa rd)
        If intLength Mod 2 = 1 Then strCreditCard = "0" & strCreditCard ' for
        amex
        For i = 1 To intLength - 1
        If i Mod 2 = 0 Then
        intEvenSum = intEvenSum + CInt(Mid(strCre ditCard, i, 1))
        ElseIf CInt(Mid(strCre ditCard, i, 1)) = 9 Then
        intOddSum = intOddSum + 9
        Else
        intOddSum = intOddSum + CInt(Mid(strCre ditCard, i, 1)) * 2 Mod 9
        End If
        Next i
        If Right(CStr(1000 - (intEvenSum + intOddSum)), 1) =
        CInt(Right(strC reditCard, 1)) Then
        CreditCardCheck Digit = True
        End If


        Exit Function
        Errorhandler:
        MsgBox "Credit Card Check Digit function failed."

        End Function
        "Grant" <Grant@nutrikid s.com> wrote in message
        news:u$vJ8X6SDH A.3132@tk2msftn gp13.phx.gbl...[color=blue]
        >
        >
        >
        >
        > Does any one know how to check the algorithm of the credit card number[/color]
        that[color=blue]
        > was entered in the text box? I want to be able to make sure the users[/color]
        enter[color=blue]
        > correct credit card number since we will process it manually via phone. I
        > want this to be done on the server side behind the code in ASP.Net. Thanks
        >
        >[/color]


        Comment

        • Cowboy \(Gregory A. Beamer\)

          #5
          Re: Credit Card Validation

          Client Side JavaScript (quite full featured):
          Compare the best free open source Software Development Software at SourceForge. Free, secure and fast Software Development Software downloads from the largest Open Source applications and software directory


          Someone has already posted a VB.NET version, so no need to go there. I have
          a C# version somewhere, if that is a need.

          --
          Gregory A. Beamer
          MVP; MCP: +I, SE, SD, DBA
          Author: ADO.NET and XML: ASP.NET on the Edge

          *************** *************** *************** *************** *************** *
          ****
          Think Outside the Box!
          *************** *************** *************** *************** *************** *
          ****
          "Grant" <Grant@nutrikid s.com> wrote in message
          news:u$vJ8X6SDH A.3132@tk2msftn gp13.phx.gbl...[color=blue]
          >
          >
          >
          >
          > Does any one know how to check the algorithm of the credit card number[/color]
          that[color=blue]
          > was entered in the text box? I want to be able to make sure the users[/color]
          enter[color=blue]
          > correct credit card number since we will process it manually via phone. I
          > want this to be done on the server side behind the code in ASP.Net. Thanks
          >
          >[/color]


          Comment

          • Ron C.

            #6
            Re: Credit Card Validation

            [color=blue]
            > Someone has already posted a VB.NET version, so no need to go there. I[/color]
            have[color=blue]
            > a C# version somewhere, if that is a need.
            >[/color]
            I would greatly appreciate the C# version :))
            Ron


            Comment

            • Cowboy \(Gregory A. Beamer\)

              #7
              Re: Credit Card Validation

              Ron:

              I have tweaked the Mod10 to make it a bit cleaner (the original was
              converted from a VB project):

              public bool CheckMod10(stri ng cardNumber)
              {
              char[] cardNums = cardNumber.Trim ().ToCharArray( );
              int cardLength = cardNums.Length ;
              bool lengthCardEven = ((cardNums.Leng th%2)==0);
              int checkValue=0;
              int currentValue=0;

              for(int counter=0;count er<cardNums.Len gth;counter++)
              {

              if((((counter%2 )==0)&&(lengthC ardEven))||(((c ounter%2)==1)&& (!lengthCardEve n
              )))
              currentValue = Convert.ToInt32 (cardNums[counter].ToString())*2;
              else
              currentValue = Convert.ToInt32 (cardNums[counter].ToString());

              if(currentValue >=10)
              currentValue -= 9;

              checkValue += currentValue;
              }

              return checkValue%10== 0 ? true : false;
              }

              --
              Gregory A. Beamer
              MVP; MCP: +I, SE, SD, DBA
              Author: ADO.NET and XML: ASP.NET on the Edge

              *************** *************** *************** *************** *************** *
              ****
              Think Outside the Box!
              *************** *************** *************** *************** *************** *
              ****
              "Ron C." <rcraven@net9.c c> wrote in message
              news:%23ou8xGpT DHA.3192@tk2msf tngp13.phx.gbl. ..[color=blue]
              > many thanks
              > Ron
              >
              >[/color]


              Comment

              Working...