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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson