function isCreditCard(st) { // Encoding only works on cards with less than 19 digits if (st.length > 19) return (false); sum = 0; mul = 1; l = st.length; for (i = 0; i < l; i++) { digit = st.substring(l-i-1,l-i); tproduct = parseInt(digit ,10)*mul; if (tproduct >= 10) sum += (tproduct % 10) + 1; else sum += tproduct; if (mul == 1) mul++; else mul--; } if ((sum % 10) == 0) return (true); else return (false); }