1// Credit Card Validation Javascript 2// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd 3 4// You have permission to copy and use this javascript provided that 5// the content of the script is not changed in any way. 6 7function validateCreditCard(s) { 8 // remove non-numerics 9 var v = "0123456789"; 10 var w = ""; 11 for (i=0; i < s.length; i++) { 12 x = s.charAt(i); 13 if (v.indexOf(x,0) != -1) 14 w += x; 15 } 16 // validate number 17 j = w.length / 2; 18 k = Math.floor(j); 19 m = Math.ceil(j) - k; 20 c = 0; 21 for (i=0; i<k; i++) { 22 a = w.charAt(i*2+m) * 2; 23 c += a > 9 ? Math.floor(a/10 + a%10) : a; 24 } 25 for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1; 26 return (c%10 == 0); 27} 28
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.