|
33 | 33 |
|
34 | 34 | }());
|
35 | 35 |
|
36 |
| -/** |
37 |
| - * IBAN is the international bank account number. |
38 |
| - * It has a country - specific format, that is checked here too |
39 |
| - */ |
40 |
| -jQuery.validator.addMethod("iban", function(value, element) { |
41 |
| - // some quick simple tests to prevent needless work |
42 |
| - if (this.optional(element)) { |
43 |
| - return true; |
44 |
| - } |
45 |
| - if (!(/^([a-zA-Z0-9]{4} ){2,8}[a-zA-Z0-9]{1,4}|[a-zA-Z0-9]{12,34}$/.test(value))) { |
46 |
| - return false; |
47 |
| - } |
48 |
| - |
49 |
| - // check the country code and find the country specific format |
50 |
| - var iban = value.replace(/ /g,'').toUpperCase(); // remove spaces and to upper case |
51 |
| - var countrycode = iban.substring(0,2); |
52 |
| - var bbancountrypatterns = { |
53 |
| - 'AL': "\\d{8}[\\dA-Z]{16}", |
54 |
| - 'AD': "\\d{8}[\\dA-Z]{12}", |
55 |
| - 'AT': "\\d{16}", |
56 |
| - 'AZ': "[\\dA-Z]{4}\\d{20}", |
57 |
| - 'BE': "\\d{12}", |
58 |
| - 'BH': "[A-Z]{4}[\\dA-Z]{14}", |
59 |
| - 'BA': "\\d{16}", |
60 |
| - 'BR': "\\d{23}[A-Z][\\dA-Z]", |
61 |
| - 'BG': "[A-Z]{4}\\d{6}[\\dA-Z]{8}", |
62 |
| - 'CR': "\\d{17}", |
63 |
| - 'HR': "\\d{17}", |
64 |
| - 'CY': "\\d{8}[\\dA-Z]{16}", |
65 |
| - 'CZ': "\\d{20}", |
66 |
| - 'DK': "\\d{14}", |
67 |
| - 'DO': "[A-Z]{4}\\d{20}", |
68 |
| - 'EE': "\\d{16}", |
69 |
| - 'FO': "\\d{14}", |
70 |
| - 'FI': "\\d{14}", |
71 |
| - 'FR': "\\d{10}[\\dA-Z]{11}\\d{2}", |
72 |
| - 'GE': "[\\dA-Z]{2}\\d{16}", |
73 |
| - 'DE': "\\d{18}", |
74 |
| - 'GI': "[A-Z]{4}[\\dA-Z]{15}", |
75 |
| - 'GR': "\\d{7}[\\dA-Z]{16}", |
76 |
| - 'GL': "\\d{14}", |
77 |
| - 'GT': "[\\dA-Z]{4}[\\dA-Z]{20}", |
78 |
| - 'HU': "\\d{24}", |
79 |
| - 'IS': "\\d{22}", |
80 |
| - 'IE': "[\\dA-Z]{4}\\d{14}", |
81 |
| - 'IL': "\\d{19}", |
82 |
| - 'IT': "[A-Z]\\d{10}[\\dA-Z]{12}", |
83 |
| - 'KZ': "\\d{3}[\\dA-Z]{13}", |
84 |
| - 'KW': "[A-Z]{4}[\\dA-Z]{22}", |
85 |
| - 'LV': "[A-Z]{4}[\\dA-Z]{13}", |
86 |
| - 'LB': "\\d{4}[\\dA-Z]{20}", |
87 |
| - 'LI': "\\d{5}[\\dA-Z]{12}", |
88 |
| - 'LT': "\\d{16}", |
89 |
| - 'LU': "\\d{3}[\\dA-Z]{13}", |
90 |
| - 'MK': "\\d{3}[\\dA-Z]{10}\\d{2}", |
91 |
| - 'MT': "[A-Z]{4}\\d{5}[\\dA-Z]{18}", |
92 |
| - 'MR': "\\d{23}", |
93 |
| - 'MU': "[A-Z]{4}\\d{19}[A-Z]{3}", |
94 |
| - 'MC': "\\d{10}[\\dA-Z]{11}\\d{2}", |
95 |
| - 'MD': "[\\dA-Z]{2}\\d{18}", |
96 |
| - 'ME': "\\d{18}", |
97 |
| - 'NL': "[A-Z]{4}\\d{10}", |
98 |
| - 'NO': "\\d{11}", |
99 |
| - 'PK': "[\\dA-Z]{4}\\d{16}", |
100 |
| - 'PS': "[\\dA-Z]{4}\\d{21}", |
101 |
| - 'PL': "\\d{24}", |
102 |
| - 'PT': "\\d{21}", |
103 |
| - 'RO': "[A-Z]{4}[\\dA-Z]{16}", |
104 |
| - 'SM': "[A-Z]\\d{10}[\\dA-Z]{12}", |
105 |
| - 'SA': "\\d{2}[\\dA-Z]{18}", |
106 |
| - 'RS': "\\d{18}", |
107 |
| - 'SK': "\\d{20}", |
108 |
| - 'SI': "\\d{15}", |
109 |
| - 'ES': "\\d{20}", |
110 |
| - 'SE': "\\d{20}", |
111 |
| - 'CH': "\\d{5}[\\dA-Z]{12}", |
112 |
| - 'TN': "\\d{20}", |
113 |
| - 'TR': "\\d{5}[\\dA-Z]{17}", |
114 |
| - 'AE': "\\d{3}\\d{16}", |
115 |
| - 'GB': "[A-Z]{4}\\d{14}", |
116 |
| - 'VG': "[\\dA-Z]{4}\\d{16}" |
117 |
| - }; |
118 |
| - var bbanpattern = bbancountrypatterns[countrycode]; |
119 |
| - // As new countries will start using IBAN in the |
120 |
| - // future, we only check if the countrycode is known. |
121 |
| - // This prevents false negatives, while almost all |
122 |
| - // false positives introduced by this, will be caught |
123 |
| - // by the checksum validation below anyway. |
124 |
| - // Strict checking should return FALSE for unknown |
125 |
| - // countries. |
126 |
| - if (typeof bbanpattern !== 'undefined') { |
127 |
| - var ibanregexp = new RegExp("^[A-Z]{2}\\d{2}" + bbanpattern + "$", ""); |
128 |
| - if (!(ibanregexp.test(iban))) { |
129 |
| - return false; // invalid country specific format |
130 |
| - } |
131 |
| - } |
132 |
| - |
133 |
| - // now check the checksum, first convert to digits |
134 |
| - var ibancheck = iban.substring(4,iban.length) + iban.substring(0,4); |
135 |
| - var ibancheckdigits = ""; |
136 |
| - var leadingZeroes = true; |
137 |
| - var charAt; |
138 |
| - for (var i =0; i<ibancheck.length; i++) { |
139 |
| - charAt = ibancheck.charAt(i); |
140 |
| - if (charAt !== "0") { |
141 |
| - leadingZeroes = false; |
142 |
| - } |
143 |
| - if (!leadingZeroes) { |
144 |
| - ibancheckdigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(charAt); |
145 |
| - } |
146 |
| - } |
147 |
| - |
148 |
| - // calculate the result of: ibancheckdigits % 97 |
149 |
| - var cRest = ''; |
150 |
| - var cOperator = ''; |
151 |
| - for (var p=0; p<ibancheckdigits.length; p++) { |
152 |
| - var cChar = ibancheckdigits.charAt(p); |
153 |
| - cOperator = '' + cRest + '' + cChar; |
154 |
| - cRest = cOperator % 97; |
155 |
| - } |
156 |
| - return cRest === 1; |
157 |
| -}, "Please specify a valid IBAN"); |
158 |
| - |
159 |
| -/** |
160 |
| - * BIC is the business identifier code (ISO 9362). This BIC check is not a guarantee for authenticity. |
161 |
| - * |
162 |
| - * BIC pattern: BBBBCCLLbbb (8 or 11 characters long; bbb is optional) |
163 |
| - * |
164 |
| - * BIC definition in detail: |
165 |
| - * - First 4 characters - bank code (only letters) |
166 |
| - * - Next 2 characters - ISO 3166-1 alpha-2 country code (only letters) |
167 |
| - * - Next 2 characters - location code (letters and digits) |
168 |
| - * a. shall not start with '0' or '1' |
169 |
| - * b. second character must be a letter ('O' is not allowed) or one of the following digits ('0' for test (therefore not allowed), '1' for passive participant and '2' for active participant) |
170 |
| - * - Last 3 characters - branch code, optional (shall not start with 'X' except in case of 'XXX' for primary office) (letters and digits) |
171 |
| - */ |
172 |
| -jQuery.validator.addMethod("bic", function(value, element) { |
173 |
| - return this.optional( element ) || /^([A-Z]{6}[A-Z2-9][A-NP-Z1-2])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test( value ); |
174 |
| -}, "Please specify a valid BIC code"); |
175 |
| - |
176 | 36 | jQuery.validator.addMethod("dateNL", function(value, element) {
|
177 | 37 | return this.optional(element) || /^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(value);
|
178 | 38 | }, "Please enter a correct date");
|
|
0 commit comments