473,385 Members | 1,312 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,385 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 4169
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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.