├── README
├── fngaba.js
└── fngaba.class.php
/README:
--------------------------------------------------------------------------------
1 | FNG ABA Tools v1.0
2 | Copyright 2012 Fake Name Generator
3 |
4 | FNG ABA Tools v1.0 by the Fake Name Generator is licensed to you under a
5 | Creative Commons Attribution-Share Alike 3.0 United States License.
6 |
7 | For full license details, please visit:
8 | http://www.fakenamegenerator.com/license.php
9 |
--------------------------------------------------------------------------------
/fngaba.js:
--------------------------------------------------------------------------------
1 | /*
2 | FNG ABA Tools v1.0
3 | Copyright 2012 Fake Name Generator
4 |
5 | FNG ABA Tools v1.0 by the Fake Name Generator is licensed to you under a
6 | Creative Commons Attribution-Share Alike 3.0 United States License.
7 |
8 | For full license details, please visit:
9 | http://www.fakenamegenerator.com/license.php
10 | */
11 |
12 | validateABA = function(t){
13 | t = String(t);
14 | n = 0;
15 | for (i = 0; i < t.length; i += 3) {
16 | n += parseInt(t.charAt(i), 10) * 3
17 | + parseInt(t.charAt(i + 1), 10) * 7
18 | + parseInt(t.charAt(i + 2), 10);
19 | }
20 |
21 | if (n != 0 && n % 10 == 0){
22 | return true;
23 | } else {
24 | return false;
25 | }
26 | }
27 |
28 | /* Example */
29 |
30 | /*
31 | alert(validateABA(121202211)); // Valid
32 | alert(validateABA(121202210)); // Invalid
33 | */
34 |
35 |
--------------------------------------------------------------------------------
/fngaba.class.php:
--------------------------------------------------------------------------------
1 |
6 |
7 | FNG ABA Tools v1.0 by the Fake Name Generator is licensed to you under a
8 | Creative Commons Attribution-Share Alike 3.0 United States License.
9 |
10 | For full license details, please visit:
11 | http://www.fakenamegenerator.com/license.php
12 | */
13 |
14 | class fngaba
15 | {
16 |
17 | public function validateABA($aba_code)
18 | {
19 | // Make sure it doesn't contain invalid characters
20 | if($aba_code != preg_replace('/[^0-9]/','',$aba_code)){
21 | return false;
22 | }
23 |
24 | // Check the length, it should be nine digits.
25 | if(strlen($aba_code) != 9){
26 | return false;
27 | }
28 |
29 | // Now run through each digit and calculate the total.
30 | $n = 0;
31 | for($i = 0; $i < 9; $i += 3) {
32 | $n += $aba_code[$i] * 3
33 | + $aba_code[$i + 1] * 7
34 | + $aba_code[$i + 2];
35 | }
36 |
37 | // If the resulting sum is an even multiple of ten (but not zero),
38 | // the aba routing number is good.
39 | if($n != 0 && $n % 10 == 0){
40 | return true;
41 | }else{
42 | return false;
43 | }
44 | }
45 |
46 | }
47 |
48 | /* Example usage: */
49 |
50 | /*
51 | // Validate ABA/routing number
52 |
53 | $fngaba = new fngaba();
54 |
55 | if($fngaba->validateABA(121202211)){
56 | echo 'Valid';
57 | }else{
58 | echo 'Invalid';
59 | }
60 | /*
61 |
62 |
--------------------------------------------------------------------------------