CFLib.org – Common Function Library Project

IsABA(number)

Last updated March 21, 2002

author

Michael Osterman

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Returns a boolean result (true or false) of whether the provided number passes the ABA check-digit algorithim. ABA ( numbers must be exactly 9 digits long. They are used to uniquely identify a bank for wire transfers and ACH (Automated Clearing House).

Return Values:
Returns a Boolean.

Example:

<cfset abaNo = 123456780>
<cfset abaNo2 = 123456789>

<cfoutput>
#abaNo# is#iif(isAba(abaNo),DE(''), DE(' not'))# a valid ABA Routing Number.<br>
    #abaNo2# is#iif(isAba(abaNo2),DE(''), DE(' not'))# a valid ABA Routing Number.<br>
</cfoutput>

Parameters:

Name Description Required
number Number you want to validate as an ABA routing number. Yes

Full UDF Source:

/**
 * Checks that a number is a valid ABA routing number.
 * 
 * @param number      Number you want to validate as an ABA routing number. 
 * @return Returns a Boolean. 
 * @author Michael Osterman (mosterman@highspeed.com) 
 * @version 1, March 21, 2002 
 */
function isABA(number) {
    var j = 0;
    var cd = 0; //check-digit value
    var result = false;
    var modVal = 0; //compared to check-digit
    var weights = ArrayNew(1);
    
    ArraySet(weights, 1, 8, 0);
    
    //set the weights for the following loop
    weights[1] = 3;
    weights[2] = 7;
    weights[3] = 1;
    weights[4] = 3;
    weights[5] = 7;
    weights[6] = 1;
    weights[7] = 3;
    weights[8] = 7;
    
    cd = Right(number,1);
    
    for (i = 1; i lte 8; i=i+1) 
    {
        j = j + ((Mid(number,i,1))*weights[i]);
    }
    
    modVal = ((10 - (j mod 10)) mod 10);
    
    if (modVal eq cd)
    {
        result = true;
    }
    
    return result;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson