cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

ABA Routing Number Validation

Does anyone have a snippet for doing ABA Routing Number validation in a Power App? I have examples in C# and JavaScript that I can try to translate but wanted to see if anyone has done this in a Power App formula already. Examples are below.

 

 C#:

        public bool RoutingNumberIsAuthentic(string routingNumber)

        {

            int sum = 0;

 

            sum = 3 * Convert.ToInt32(routingNumber.Substring(0, 1)) + 7 *

                      Convert.ToInt32(routingNumber.Substring(1, 1)) +

                      Convert.ToInt32(routingNumber.Substring(2, 1)) +

                  3 * Convert.ToInt32(routingNumber.Substring(3, 1)) + 7 *

                      Convert.ToInt32(routingNumber.Substring(4, 1)) +

                      Convert.ToInt32(routingNumber.Substring(5, 1)) +

                  3 * Convert.ToInt32(routingNumber.Substring(6, 1)) + 7 *

                      Convert.ToInt32(routingNumber.Substring(7, 1)) +

                      Convert.ToInt32(routingNumber.Substring(8, 1));

            return ((sum % 10) == 0);

        }

 

JaveScript:

  // Run through each digit and calculate the total.

  n = 0;

  for (i = 0; i < t.length; i += 3) {

    n += parseInt(t.charAt(i),     10) * 3

      +  parseInt(t.charAt(i + 1), 10) * 7

      +  parseInt(t.charAt(i + 2), 10);

  }

  // 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;

  else

    return false;

}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@rlally
Here’s how I would check whether it’s a valid ABA number.

Len(TextInput_ABA.Text) = 9
And
Mod(
(
Value(Mid(TextInput_ABA.Text,1,1))
+ Value(Mid(TextInput_ABA.Text,4,1))
+ Value(Mid(TextInput_ABA.Text,7,1))
) * 3
+ (
Value(Mid(TextInput_ABA.Text,2,1))
+ Value(Mid(TextInput_ABA.Text,5,1))
+ Value(Mid(TextInput_ABA.Text,8,1))
) * 7
+ (
Value(Mid(TextInput_ABA.Text,3,1))
+ Value(Mid(TextInput_ABA.Text,6,1))
+ Value(Mid(TextInput_ABA.Text,9,1))
) * 1,
10) = 0

I’ll clean up the formatting later. I am typing from my mobile right now.

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

View solution in original post

10 REPLIES 10
Highlighted
Super User III
Super User III

@rlally 
I would suggest posting an example of what and ABA number looks like and the rules for validation.  I am not aware of how they work but I'm sure its doable.

 

Pro-tip: if you 'lower-the-bar' for others to understand your problem by explaining it without  C# and Javascript I'm sure you will get more responses.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted

@mdevaney - Thank you, I sincerely appreciate the feedback.

ABA numbers are 9-digit numbers used by banks in processing transactions. This site (where I got the JavaScript example from) explains the actual algorithm behind it (pasted below in case that link becomes dead): http://www.brainjar.com/js/validation/

------------------------------------------------------------------------------------------------------------------------------------------

The Checksum Algorithm
Here's how the algorithm works. First the code strips out any non-numeric characters (like dashes or spaces) and makes sure the resulting string's length is nine digits,

7 8 9 4 5 6 1 2 4

Then we multiply the first digit by 3, the second by 7, the third by 1, the fourth by 3, the fifth by 7, the sixth by 1, etc., and add them all up.

(7 x 3) + (8 x 7) + (9 x 1) +
(4 x 3) + (5 x 7) + (6 x 1) +
(1 x 3) + (2 x 7) + (4 x 1) = 160

If this sum is an integer multiple of 10 (e.g., 10, 20, 30, 40, 50,...) then the number is valid, as far as the checksum is concerned.

------------------------------------------------------------------------------------------------------------------------------------------

An example of a valid one is 123123123.

 

My goal is to ensure that when a user enters a routing number into a TextInput field in my Power App, I can determine that the number entered is at least potentially a valid ABA number.

 

Highlighted

@rlally 
This is the type of question I enjoy answering.  Thanks for the details.  I will look into it 🙂

Highlighted

@rlally 
Can you please give one or more sample ABA numbers?  I noticed your example said it could have non numerical characters.  I'm just not sure what you are using as an input to test.

Highlighted

@mdevaney 

 

If they change it to a numerical on the text input then it will only allow numbers to be typed in. That might help with part of it.

Highlighted

@mdevaney and @mdevaney 

 

Thank you both!

 

Leading zeroes are possible, but all 9 digits must be numbers (I can check for that, it's the check sum piece I struggle with).

Here are some examples of good ones that should pass:

123123123

011103093
067014822
211274450
211370545
054001725


Here are some examples of bad ones that should fail:

011222333

111111111

222222222

221221221

321321321

444444444

123456789

 

Highlighted

@mdevaney  is a numbers guy so I am going to let him take the lead on this. Right up his alley! 🙂

 

It can totally be done and I am sure he will come up with the best way to do it. 

Highlighted

@rlally
Here’s how I would check whether it’s a valid ABA number.

Len(TextInput_ABA.Text) = 9
And
Mod(
(
Value(Mid(TextInput_ABA.Text,1,1))
+ Value(Mid(TextInput_ABA.Text,4,1))
+ Value(Mid(TextInput_ABA.Text,7,1))
) * 3
+ (
Value(Mid(TextInput_ABA.Text,2,1))
+ Value(Mid(TextInput_ABA.Text,5,1))
+ Value(Mid(TextInput_ABA.Text,8,1))
) * 7
+ (
Value(Mid(TextInput_ABA.Text,3,1))
+ Value(Mid(TextInput_ABA.Text,6,1))
+ Value(Mid(TextInput_ABA.Text,9,1))
) * 1,
10) = 0

I’ll clean up the formatting later. I am typing from my mobile right now.

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

View solution in original post

Highlighted

@mdevaney Perfect! This is exactly what I was hoping for and it works beautifully, thank you, thank you, thank you!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (5,996)