| 4 |
5 |
6 |
3 |
9 |
6 |
0 |
1 |
2 |
2 |
0 |
0 |
1 |
9 |
9 |
9 |
|
| x2 |
x1 |
x2 |
x1 |
x2 |
x1 |
x2 |
x1 |
x2 |
x1 |
x2 |
x1 |
x2 |
x1 |
x2 |
x1 |
|
| 4x2 = 8 |
5 |
6x2 = 12 |
3 |
9x2 = 18 |
6 |
0x2 = 0 |
1 |
2x2 = 4 |
2 |
0x2 = 0 |
0 |
1x2 = 2 |
9 |
9x2 = 18 |
9 |
|
| 8 |
5 |
(12) 1+2 = 3 |
3 |
(18) 1+8 = 9 |
6 |
0 |
1 |
4 |
2 |
0 |
0 |
2 |
9 |
(18) 1+8 = 9 |
9 |
|
| 8 + |
5 + |
3 + |
3 + |
9 + |
6 + |
0 + |
1 + |
4 + |
2 + |
0 + |
0 + |
2 + |
9 + |
9 + |
9 |
= 70 |
Now we mod the sum by 10, if the remian is Zero the nuber is valid
OK : 70 Mod 10 = 0
JavaScript Luhn Credit Card number Validation
<script>
var cardValid=function(cardNo){
var sum = 0, iNum;
for( var i in cardNo+='' ){
iNum = parseInt(cardNo[i]);
sum += i%2?iNum:iNum>4?iNum*2%10+1:iNum*2;
}
return !(sum%10);
};
</script>
Asp vb script IsraCard Credit Card number Validation (8 or 9 digits)
<%
Function IsraCardCheck(strNumber)
comp1 = "987654321"
comp2 = strNumber
srez = 0
if len(comp2) < 9 then comp2 = "0" & comp2
for i = 1 to 9
a = mid(comp1, i, 1)
b = mid(comp2, i, 1)
c = a * b
srez = srez + c
next
if srez mod 11 = 0 then
IsraCheck = true
else
IsraCheck = false
end if
End Function
%>