473,769 Members | 6,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4190
Rob wrote on 22 dec 2006 in microsoft.publi c.inetserver.as p.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(sNum ber)
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 ValidateCreditC ard(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.

ValidateCreditC ard = 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.IgnoreCas e = True
regEx.Global = True
msCCNumber = regEx.Replace(C CNumber, "")

Dim CurrentYear: CurrentYear = Year(Now())
If ((Len(msCCNumbe r) = 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
ValidateCreditC ard = regEx.Test(msCC Number) And Mod10(msCCNumbe r)

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
1444
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 while ago that did this but need an asp script. Appreciate any help.
9
1487
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 searched http://www.hotscripts.com/ and a couple of other sites with no luck yet. Do you have any suggestions? What would you think a script like that typically be called? Book Collections? Article Database? I think I haven't hit on the right...
2
1856
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 browser-based editor for *static* HTML pages, like this:
5
1630
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
1898
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 button, and the browser launches several instances of Google with the single word + other search terms. I would like to have this script because I'm a translator and frequently need to look up the meaning of words. I Google using
12
1659
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 translate these instructions into something that can be processed automatically, so I have used the Command pattern to set up a set of commands that correspond to the various instructions in the document.
2
2976
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 url page
11
3322
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 'thoughful' suggestion based on their answers. In terms of the logic involved with the actual script: I've mulled it over and thoroughly broken my brain, trying to devise a complicated 'scoring system' (with different answers giving different...
0
1245
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 number of images upload today or total number of images already hosted on the sever.for my script,all the uploaded images are saved on the a single file.take a look the picture,this is what i want to do at my site....
1
1908
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, PHP brands, everythingauction, etc. If you do a search, google, yahoo, so on, you'll come up with most of these. There is one that looks the best, AJ Square. But they are in India and their site as a forum, but nobody really has written, so I...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.