473,390 Members | 1,334 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,390 software developers and data experts.

looking for mod 10 script

Rob
I'm looking for a mod 10 script that you know to work well. I have googled
and found a few different ones but I would like a 2nd opinion. If you can
please link me to a mod 10 script that you have used/implimented I would
appreciate it.

Ideally I would like a vbscript over javascript so we can have it
implimented on an access db as well.

Thanks.
Dec 22 '06 #1
2 4170
Rob wrote on 22 dec 2006 in microsoft.public.inetserver.asp.general:
I'm looking for a mod 10 script
You mean a mod10 function, I think.

If not, what is a mod 10 script?
that you know to work well. I have
googled and found a few different ones but I would like a 2nd opinion.
If you can please link me to a mod 10 script that you have
used/implimented I would appreciate it.
Jscript:

function mod10function(x){
return x % 10;
};

vbscript:

function mod10function(x)
mod10function = x mod 10
end function
Ideally I would like a vbscript over javascript so we can have it
implimented on an access db as well.
"vbscript over javascript" what is that?

Can you implement that on a database, a database being only storage?

Who is "we", ideally?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 22 '06 #2
On Fri, 22 Dec 2006 09:05:33 -0800, "Rob" <no****@nospam.comwrote:
in <O9**************@TK2MSFTNGP03.phx.gbl>
>I'm looking for a mod 10 script that you know to work well. I have googled
and found a few different ones but I would like a 2nd opinion. If you can
please link me to a mod 10 script that you have used/implimented I would
appreciate it.

Ideally I would like a vbscript over javascript so we can have it
implimented on an access db as well.

Thanks.
The best article I found on that subject is still available here:

http://www.sitepoint.com/article/car...tion-class-php

And here is a VBScript version of that.

<%Const CARD_TYPE_MC = 0
Const CARD_TYPE_VS = 1
Const CARD_TYPE_AX = 2
Const CARD_TYPE_DC = 3
Const CARD_TYPE_DS = 4
Const CARD_TYPE_JC = 5

Dim msCCName, msCCType, msCCNumber, msCCExpMonth, msCCExpYear

Function Mod10(sNumber)

Dim CardNumber: CardNumber = StrReverse(sNumber)
Dim NumberSum: NumberSum = 0

Dim lngN
For lngN = 1 To Len(CardNumber)
Dim CurrentNumber: CurrentNumber = Mid(CardNumber, lngN, 1)

' Double every second digit
If (lngN Mod 2 = 0) Then CurrentNumber = CurrentNumber * 2

' Add digits of 2-digit numbers together
If (CurrentNumber 9) Then
Dim FirstNumber: FirstNumber = CurrentNumber Mod 10
Dim SecondNumber: SecondNumber = (CurrentNumber - FirstNumber) / 10
CurrentNumber = FirstNumber + SecondNumber
End If

NumberSum = NumberSum + CurrentNumber
Next

Mod10 = ((NumberSum Mod 10) = 0)

End Function

Function ValidateCreditCard(CCName, CCType, CCNumber, CCExpMonth, CCExpYear)

' http://www.sitepoint.com/print/card-...tion-class-php
'* Mastercard: Must have a prefix of 51 to 55, and must be 16 digits in length.
'* Visa: Must have a prefix of 4, and must be either 13 or 16 digits in length.
'* American Express: Must have a prefix of 34 or 37, and must be 15 digits in length.
'* Diners Club: Must have a prefix of 300 to 305, 36, or 38, and must be 14 digits in length.
'* Discover: Must have a prefix of 6011, and must be 16 digits in length.
'* JCB: Must have a prefix of 3, 1800, or 2131, and must be either 15 or 16 digits in length.

ValidateCreditCard = False
If ((Len(CCName) = 0) Or (Len(CCType) = 0) Or (Len(CCNumber) = 0) Or (Len(CCExpMonth) = 0) Or (Len(CCExpYear) = 0)) Then Exit Function
msCCName = CCName

Select Case LCase(CCType)
Case "mc":
Case "mastercard":
Case "m":
Case "1":
msCCType = CARD_TYPE_MC

Case "vs":
Case "visa":
Case "v":
Case "2":
msCCType = CARD_TYPE_VS

Case "ax":
Case "american express":
Case "a":
Case "3":
msCCType = CARD_TYPE_AX

Case "dc":
Case "diners club":
Case "4":
msCCType = CARD_TYPE_DC

Case "ds":
Case "discover":
Case "5":
msCCType = CARD_TYPE_DS

Case "jc":
Case "jcb":
Case "6":
msCCType = CARD_TYPE_JC

Case Else
Exit Function
End Select

Dim regEx: Set regEx = New RegExp
regEx.Pattern = "[^0-9]"
regEx.IgnoreCase = True
regEx.Global = True
msCCNumber = regEx.Replace(CCNumber, "")

Dim CurrentYear: CurrentYear = Year(Now())
If ((Len(msCCNumber) = 0) Or (CCExpMonth < 1) Or (CCExpMonth 12) Or (CCExpYear < CurrentYear) Or (CCExpYear (CurrentYear + 10))) Then Exit Function
msCCExpMonth = CCExpMonth
msCCExpYear = CCExpYear

Select Case msCCType
Case CARD_TYPE_MC:
Dim ValidFormat: ValidFormat = "^5[1-5][0-9]{14}$"

Case CARD_TYPE_VS:
ValidFormat = "^4[0-9]{12}([0-9]{3})?$"

Case CARD_TYPE_AX:
ValidFormat = "^3[47][0-9]{13}$"

Case CARD_TYPE_DC:
ValidFormat = "^3(0[0-5]|[68][0-9])[0-9]{11}$"

Case CARD_TYPE_DS:
ValidFormat = "^6011[0-9]{12}$"

Case CARD_TYPE_JC:
ValidFormat = "^(3[0-9]{4}|2131|1800)[0-9]{11}$"

Case Else:
ValidFormat = False
End Select
regEx.Pattern = ValidFormat
ValidateCreditCard = regEx.Test(msCCNumber) And Mod10(msCCNumber)

End Function%>

---
This posting is provided "AS IS" with no warranties and no guarantees either express or implied.

Stefan Berglund
Dec 22 '06 #3

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

Similar topics

5
by: Burt Lewis | last post by:
Hi, I'm looking for a sample script I can modify that will calculate the price of a PC based on chosen selections and prices such as case, hard drive, drives, ram, etc. I had a Perl script a...
9
by: crispy | last post by:
I am looking for a free (or inexpensive) script to list the book and journal publications created within a college department and be able to sort them by author and year of publication. I've...
2
by: David Winter | last post by:
I'm not a developer myself, but I am looking for something that maybe one of you guys - has done - knows about - would like to do - yes, I have a small budget for this. :) The basic idea: A...
5
by: Ed | last post by:
I am looking for a script that hides your email address in your web page from spiders, robots, etc.... Can someone tell me where to find one and do they work? Thanks Ed
3
by: Voetleuce en f?nsievry | last post by:
G'day I'm looking for a script that can search multiple instances of Google (or other search engines optionally). The user types in a single word in the text field, presses ENTER or the submit...
12
by: Charles Law | last post by:
Hi guys A bit of curve ball here ... I have a document (Word) that contains a series of instructions in sections and subsections (and sub-subsections). There are 350 pages of them. I need to...
2
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a...
11
by: admin | last post by:
Hi all, First time poster here... I'm a webmaster and I'd like to add a simple script to my website which will allow users to fill in a brief multiple choice questionaire, and then provide a...
0
by: idutnet | last post by:
Hello! i am a kid on the web hosting. i have a free image hosting site http://www.idut.net , and looking for some help, thanks in advance. #1)how can i set the script to count the total...
1
by: vinniegolfs | last post by:
Been all over the internet for months now. Looking for a script that has the feel and look of ebay, but I have some programming ideas to change the way some of the script works. I've seen Rainworx,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.