Hi,
I used JQuery here. You might want to use it if you're going to use this code to verify routing numbers according to a very simple algorithm that simply uses the 371 371 371 checksum.
function confirmRoutingNumber(strRoutingNumber)
{
var routingArray = new Array();
var total = 0;
var i = 0;
//alert("Inside confirmRoutingNumber function");
for(i = 0; i < strRoutingNumber.length ; i++)
{
routingArray[i] = Number(strRoutingNumber.charAt(i))
//alert("I: " + i + " Digit: " + routingArray[i]);
//alert("I: " + i + " Digit: " + accountArray[i]);
if ( i % 3 == 0 )
{
routingArray[i] = routingArray[i] * 3;
}
else if (i % 3 == 1)
{
routingArray[i] = routingArray[i] * 7;
}
total = total + routingArray[i];
}
//alert("Routing Number Total: " + total);
if (total % 10 === 0)
{
return true;
}
else
{
return false;
}
}
I used JQuery here. You might want to use it if you're going to use this code to verify routing numbers according to a very simple algorithm that simply uses the 371 371 371 checksum.
function confirmRoutingNumber(strRoutingNumber)
{
var routingArray = new Array();
var total = 0;
var i = 0;
//alert("Inside confirmRoutingNumber function");
for(i = 0; i < strRoutingNumber.length ; i++)
{
routingArray[i] = Number(strRoutingNumber.charAt(i))
//alert("I: " + i + " Digit: " + routingArray[i]);
//alert("I: " + i + " Digit: " + accountArray[i]);
if ( i % 3 == 0 )
{
routingArray[i] = routingArray[i] * 3;
}
else if (i % 3 == 1)
{
routingArray[i] = routingArray[i] * 7;
}
total = total + routingArray[i];
}
//alert("Routing Number Total: " + total);
if (total % 10 === 0)
{
return true;
}
else
{
return false;
}
}
No comments:
Post a Comment