473,411 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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
Nov 17 '05 #1
6 10936
Take a look at this site.

http://www.merriampark.com/anatomycc.htm

"Grant" <Gr***@nutrikids.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...


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

Nov 17 '05 #2
I have a credit card validation sample on my web site in the code library:
www.aboutfortunate.com

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:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Grant" <Gr***@nutrikids.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...


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

Nov 17 '05 #3
Here is an access function for generic card testing which might help you
also.

Function CreditCardCheckDigit(strCreditCard As String) As Boolean
Dim intLength As Integer
Dim intEvenSum As Integer
Dim intOddSum As Integer
Dim i As Integer
CreditCardCheckDigit = False
On Error GoTo Errorhandler
intEvenSum = 0
intOddSum = 0
intLength = Len(strCreditCard)
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(strCreditCard, i, 1))
ElseIf CInt(Mid(strCreditCard, i, 1)) = 9 Then
intOddSum = intOddSum + 9
Else
intOddSum = intOddSum + CInt(Mid(strCreditCard, i, 1)) * 2 Mod 9
End If
Next i
If Right(CStr(1000 - (intEvenSum + intOddSum)), 1) =
CInt(Right(strCreditCard, 1)) Then
CreditCardCheckDigit = True
End If
Exit Function
Errorhandler:
MsgBox "Credit Card Check Digit function failed."

End Function
"Grant" <Gr***@nutrikids.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...


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

Nov 17 '05 #4
Client Side JavaScript (quite full featured):
http://freshmeat.net/releases/112097/

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" <Gr***@nutrikids.com> wrote in message
news:u$**************@tk2msftngp13.phx.gbl...


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

Nov 17 '05 #5
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.

I would greatly appreciate the C# version :))
Ron
Nov 17 '05 #6
Ron:

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

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

for(int counter=0;counter<cardNums.Length;counter++)
{

if((((counter%2)==0)&&(lengthCardEven))||(((counte r%2)==1)&&(!lengthCardEven
)))
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." <rc*****@net9.cc> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
many thanks
Ron

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kaptain kernel | last post by:
I'm implementing a simple credit card number check on my website, in order to trap user errors. it doesn't validate with the bank, but validates against certain known rules (e.g. Amex always begins...
10
by: dries | last post by:
A friend of mine has a problem with his credit card validation routine and it is probably a simple thing to solve but I cannot find it. It has to do with the expiry dates. What happens is that as...
7
by: gj | last post by:
I have an application in Access 97 I will be rewriting in the latest version of Access in 6 months. In the meantime, does anyone know of an ActiveX control I can add into an Access 97 form to...
4
by: Michelle A. | last post by:
I have a form that takes in a credit card number, just a series of numbers 1234123412341234. When they get to the "Review" page and display all the information a user has entered, I would like the...
7
by: Sandy | last post by:
I need a credit card validator. Is there reliable code already written that anyone knows of? I have come across a few things; i.e. the Luhn-10 algorithm, but don't know if that still applies or...
3
by: tshad | last post by:
I am looking to connect my asp.net pages to a credit card processor, such as ICVerify. I used to be able to read and write to a text file: credit card authorizations, cancelations, get responses...
1
by: Bill D'Innocenzo | last post by:
There are many functions available that implement credit card identification and number validation -- meaning you can decide, based on the number, if a card is a MasterCard or Visa and if the...
1
by: securedcardss | last post by:
http://card.2youtop.info secured credit card card credit instant secured card cash credit secured card
4
code green
by: code green | last post by:
Data Protection etc.... shouldn't be there. How do I find credit card numbers buried amongst any length of text. Googling finds credit card validation claims, which are too complicated. I need...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.