Skip to content

Instantly share code, notes, and snippets.

@etodanik
Last active May 11, 2020 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save etodanik/5851338 to your computer and use it in GitHub Desktop.
Save etodanik/5851338 to your computer and use it in GitHub Desktop.
Checks the validity of a given Isracard credit card number
function isracardCheck(num) {
if(num.length < 8 || num.length > 9) return false;
var diff = "987654321",
sum = 0,
a = 0,
b = 0,
c = 0;
if(num.length < 9) num = "0" + num;
for(var i=1;i<9;i++){
sum += parseInt(diff.substr(i,1))*parseInt(num.substr(i,1));
}
if(sum % 11 == 0) return true;
else return false;
}
@etodanik
Copy link
Author

I posted an article explaining the verification process:
http://povolotski.me/2013/09/24/isracard-credit-card-number-validation-2/

@avimar
Copy link

avimar commented Nov 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment