Commerce
|
|
|
|
<?php
function abavalidate($aba)
{
// First, check for 9 digits and non-numeric characters.
if (ereg("^[0-9]{9}$",$aba))
{
$n = 0;
for ($i = 0; $i < 9; $i += 3)
{
$n += (substr($aba,$i,1) * 3)
+ (substr($aba,$i + 1,1) * 7)
+ (substr($aba,$i + 2,1));
}
// If the resulting sum is an even multiple of ten (but not zero),
// the aba routing number is good.
if ($n != 0 && $n % 10 == 0)
{
return(true); // found good aba
}
else
{
return(false);
}
}
else
{
return(false);
}
}
?>
|
|
|
Usage Example
|
include("include/abavalidate.php");
if (!abavalidate($bankID))
{
$errmsg[] = "The Bank I.D. Number is invalid. It must be 9 digits (numbers only) and entered exactly as it appears on the bottom of your check.";
}
|
|
|
Rate This Script
|
|
|
|