Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Validating Routing Numbers - Algorithm
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Validating Routing Numbers - Algorithm

 Post Reply Post Reply
Author
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Topic: Validating Routing Numbers - Algorithm
    Posted: 19 May 2015 at 2:27pm
Good Morning,
 
I'm trying to validate ABA Routing Numbers within a field on a PDF.  I've tried various ways (one way is below).  I can't seem to get it to work.  Any help will be greatly appreciated.
 
// Check 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;
}
Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1116
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 2:48pm
What happens when you use the code?
Back to Top
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 3:02pm
Absolutely nothing happens.  No errors, no pop-up alerts, nothing.  :-(
 
Thanks!
Back to Top
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 3:10pm
Basically, I'm trying to accomplish this:
 
 
Back to Top
Horndoggie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 15 Jul 2011
Location: USA
Points: 758
Post Options Post Options   Quote Horndoggie Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 3:16pm
Looking at this in the link: Note that even if a number passes this test, it does not necessarily mean that it is valid. The number may not, in fact, be assigned to any financial institution.
Wouldn't it be better to validate against a database of actual banks?  With your method you could get a valid number, but the wrong bank which could lead to huge issues.
Doug
Back to Top
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 3:28pm
Unfortunately, I do not have the ability to validate against a database of actual banks at this time.
 
I was also trying to get / use the "mod 10" algorithm; but, nothing seems to happen.
 
 
Thanks!
Back to Top
BAlheit View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 1116
Post Options Post Options   Quote BAlheit Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 3:51pm
Where did you use the code?
Back to Top
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 4:13pm
Within the field.  Calculate > Custom Calculation Script
 
Thanks!
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 634
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 5:42pm
The code needs to be adjusted and then used as a custom validation script, so you could accept or reject the value. Try using this code for that purpose (note I didn't test it, I just used the code you provided as-is, after fixing one error it had):

function validateABARoutingNumber(t) {
    // Check 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;
  
}

if (event.value) {
    event.rc = validateABARoutingNumber(event.value);
}


Edited by try67 - 19 May 2015 at 5:43pm
- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 6:02pm
Thank you!  I will give it a try.
Back to Top
skowalczyk View Drop Down
New Member
New Member


Joined: 06 Oct 2011
Points: 15
Post Options Post Options   Quote skowalczyk Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 6:15pm
It seems to be working.  Thank you, try67!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.016 seconds.