Add to Favorites    Make Home Page 8158 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Strings Home » Credit Card Validation - Validates a credit card string

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Credit Card Validation - Validates a credit card string
Description
Category ASP » Strings
Hits 379950
Code Select and Copy the Code
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER> ' ======================================== ' _ccard: credit card validation ' ' requires: _int, _str ' ' updated on 16.12.2000 ' ======================================== Function Luhn(s) Dim i, iOdd, iEven, sInv, iNum i = 1 iOdd = 0 iEven = 0 sInv = StrReverse(s) Do While (i<=Len(sInv)) If Odd(i) Then iOdd = iOdd + CByte(Mid(sInv, i, 1)) Else iNum = 2 * CByte(Mid(sInv, i, 1)) If (iNum > 9) Then iEven = iEven + 1 + (iNum - 10) Else iEven = iEven + iNum End If End If i = i + 1 Loop Luhn = (i>1) And ((iOdd + iEven) Mod 10 = 0) End Function Function IsMaster(s) IsMaster = IsLen(s, 16) And IInside(CLng(Left(s, 2)), 51, 55) End Function Function IsVISA(s) IsVisa = IsPrefix(s, "4") And (IsLen(s, 13) Or IsLen(s, 16)) End Function Function IsAmex(s) IsAmex = IsLen(s, 15) And (IsPrefix(s, "34") Or IsPrefix(s, "37")) End Function Function IsDiners(s) IsDiners = IsLen(s, 14) And (IsPrefix(s, "36") Or _ IsPrefix(s, "38") Or IInside(CLng(Left(s, 3)), 300, 305)) End Function Function IsDiscover(s) IsDiscover = IsLen(s, 16) And IsPrefix(s, "6011") End Function Function IsRoute(s) IsRoute = IsLen(s, 15) And (IsPrefix(s, "2014") Or _ IsPrefix(s, "2049")) End Function Function IsJCB(s) IsJCB = (IsLen(s, 15) And (IsPrefix(s, "2131") Or _ IsPrefix(s, "1800")) Or (IsLen(s, 16) And _ IsPrefix(s, "3"))) End Function ' This routine checks for a valid credit card number, according ' to the prefixes and lengths below, and to Luhn's algorithm. ' ' Card Type Prefix Length ' ' MasterCard 51-55 16 ' VISA 4 13, 16 ' American Express 34, 37 15 ' Diner's Club 300-305, 36, 38 14 ' Carte Blanche 300-305, 36, 38 14 ' Discover 6011 16 ' enRoute 2014, 2049 15 ' JCB 3 16 ' JCB 2131, 1800 15 Function IsCardNumber(sCard, ccType) Dim ccMin, ccMax, minLen, maxLen, result, ccMaster,_ ccVISA, ccAmex, ccDiners, ccCarteB, ccDiscover,_ ccenRoute, ccJCB ccMin = 0 ccMax = 7 minLen = 13 maxLen = 16 result = False sCard = Trim(sCard) ccMaster = 0 ccVISA = 1 ccAmex = 2 ccDiners = 3 ccCarteB = 4 ccDiscover = 5 ccenRoute = 6 ccJCB = 7 If (IInside(ccType, ccMin, ccMax)) Then If (IInside(Len(sCard), minLen, maxLen)) Then Select Case ccType Case ccMaster result = IsMaster(sCard) Case ccVISA result = IsVISA(sCard) Case ccAmex result = IsAmex(sCard) Case ccDiners result = IsDiners(sCard) Case ccCarteB result = IsDiners(sCard) Case ccDiscover result = IsDiscover(sCard) Case ccenRoute result = IsRoute(sCard) Case ccJCB result = IsJCB(sCard) End Select End If End If If result Then result = Luhn(sCard) End If IsCardNumber = result End Function </SCRIPT>

Related Source Codes

Script Name Author
��������������������� VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=195


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review