Wednesday, July 27, 2011

Credit Card Validation

function validateCreditCard(s) {
function cardval(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) { x = s.charAt(i); if (v.indexOf(x,0) != -1) w += x; } // validate number j = w.length / 2; if (j < 6.5 || j > 8 || j == 7) return false;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i return (c%10 == 0);
}

No comments:

Post a Comment