CFLib.org – Common Function Library Project

IsABA(number)

Last updated March 21, 2002
Download UDF

author

Michael Osterman                                  Michael Osterman

Version: 1 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 0 time(s). Average Rating: 0

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:

<cfscript>
/**
* 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;
}
</cfscript>

Search CFLib.org


Latest Additions

Shawn Porter Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson