<%
function isCreditCard(cardNo)
isCreditCard = false
lCard=len(cardNo)
lC=right(cardNo,1)
cStat=0
for i=(lCard-1) to 1 step -1
tempChar= mid(cardNo,i,1)
d=cint(tempChar)
if lcard mod 2 = 1 then
temp=d*(1+((i+1) mod 2))
else
temp=d*(1+(i mod 2))
end if
if temp < 10 then
cStat = cStat + temp
else
cStat = cStat + temp - 9
end if
next
cStat = (10-(cStat mod 10)) mod 10
if cint(lC) = cStat then isCreditCard = true
end function
' **************** AS A TEST ****************
'
' 4111111111111111 should pass (test number)
' 4111111111111112 should fail
response.write("1:" & isCreditCard("4111111111111111") & "<br>")
response.write("2:" & isCreditCard("4111111111111112") & "<br>")
%>