├── .gitignore
├── Gruntfile.js
├── MIT-LICENSE.md
├── README.md
├── jquery
├── README.md
├── jquery.is.js
├── jquery.is.min.js
└── src
│ ├── intro.js
│ ├── nonroot.js
│ └── outro.js
├── nodejs
├── README.md
├── is.js
└── src
│ ├── intro.js
│ └── outro.js
├── package.json
├── src
├── check.js
├── deep.js
├── return.js
└── trim.js
├── testem.json
├── tests
├── is.js
└── jquery.js
└── vanilla
├── README.md
├── is.js
├── is.min.js
└── src
├── intro.js
└── outro.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | module.exports = function (grunt) {
2 | var banner = '/** \n' +
3 | ' * is.js - v<%= pkg.version %>\n' +
4 | ' * <%= pkg.description %>\n' +
5 | ' * <%= pkg.homepage %>\n' +
6 | ' *\n' +
7 | ' * Licensed under the MIT license.\n' +
8 | ' * Copyright (c) 2013 <%= pkg.author.name %>\n' +
9 | ' * <%= pkg.author.url %>\n' +
10 | ' */\n';
11 |
12 | // Project configuration.
13 | grunt.initConfig({
14 | pkg: grunt.file.readJSON('package.json'),
15 | concat: {
16 | options: {
17 | banner: banner,
18 | separator: ''
19 | },
20 | dist: {
21 | files: {
22 | 'jquery/jquery.is.js': [
23 | 'jquery/src/intro.js',
24 | 'jquery/src/nonroot.js',
25 | 'src/deep.js',
26 | 'src/check.js',
27 | 'src/return.js',
28 | 'jquery/src/outro.js'
29 | ],
30 | 'vanilla/is.js': [
31 | 'vanilla/src/intro.js',
32 | 'src/deep.js',
33 | 'src/check.js',
34 | 'src/trim.js',
35 | 'src/return.js',
36 | 'vanilla/src/outro.js'
37 | ],
38 | 'nodejs/is.js': [
39 | 'nodejs/src/intro.js',
40 | 'src/deep.js',
41 | 'src/check.js',
42 | 'src/trim.js',
43 | 'src/return.js',
44 | 'nodejs/src/outro.js'
45 | ]
46 | }
47 | }
48 | },
49 | uglify: {
50 | options: {
51 | banner: banner
52 | },
53 | dist: {
54 | files: {
55 | 'jquery/jquery.is.min.js': 'jquery/jquery.is.js',
56 | 'vanilla/is.min.js': 'vanilla/is.js'
57 | }
58 | }
59 | }
60 | });
61 |
62 | // Load the plugin that provides the "uglify" task.
63 | grunt.loadNpmTasks('grunt-contrib-uglify');
64 | grunt.loadNpmTasks('grunt-contrib-concat');
65 |
66 | // Default task(s).
67 | grunt.registerTask('default', ['concat', 'uglify']);
68 | };
--------------------------------------------------------------------------------
/MIT-LICENSE.md:
--------------------------------------------------------------------------------
1 | # The MIT License (MIT)
2 |
3 | Copyright (c) 2013 Ragnar Þór Valgeirsson (rthor) [http://rthor.is](http://rthor.is)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # is.js
2 |
3 | Check your data against regular expressions or known keywords (see Keyword section). Different versions for different platforms are availible.
4 |
5 | Currently these *plugins* are stable:
6 |
7 | - jQuery
8 | - Vanilla JavaScript
9 | - Node.js Module
10 |
11 | I wrote a really short blog post about the project a while ago, which can be read at [rthor.is/javascript/cross-plugin-javascript-project-isjs](http://rthor.is/javascript/cross-plugin-javascript-project-isjs/). *Note that some code examples are out of date*.
12 |
13 | ## Keywords
14 |
15 | **cc (Credit cards)**
16 |
17 | Works for:
18 |
19 | American Express
20 |
21 | Discover
22 |
23 | MasterCard
24 |
25 | Visa
26 |
27 | *or any*
28 |
29 | ```javascript
30 | // Example (vanilla JS)
31 | is('0000000000000000', 'cc:any'); // Returns true
32 | is('4000000000000000', 'cc:Visa'); // Returns true
33 | ```
34 |
35 | **datetime (Date and time)**
36 |
37 | Format: 1996-12-19T16:39:57-08:00
38 |
39 | ```javascript
40 | // Example (vanilla JS)
41 | is('1996-12-19T16:39:57-08:00', 'datetime'); // Returns true
42 | ```
43 |
44 | **isbn (ISBN)**
45 |
46 | ISBN 10
47 |
48 | ```javascript
49 | // Example (vanilla JS)
50 | is('0-85131-041-9', 'isbn'); // Returns true
51 | is('0851310419', 'isbn'); // Returns true
52 | ```
53 |
54 | ISBN 13
55 |
56 | ```javascript
57 | // Example (vanilla JS)
58 | is('978-1-56619-909-4', 'isbn'); // Returns true
59 | is('9781566199094', 'isbn'); // Returns true
60 | ```
61 |
62 | **latlng (Latitude and longitude)**
63 |
64 | Latitude
65 |
66 | ```javascript
67 | // Example (vanilla JS)
68 | is('64.163296', 'latlng'); // Returns true
69 | ```
70 |
71 | Longitude
72 |
73 | ```javascript
74 | // Example (vanilla JS)
75 | is('-21.859328', 'latlng'); // Returns true
76 | ```
77 |
78 | **phone (Phone numbers)**
79 |
80 | Argentina (ar)
81 |
82 | Australia (au)
83 |
84 | France (fr)
85 |
86 | Iceland (is)
87 |
88 | United Kingdom (uk)
89 |
90 | United States of America (us)
91 |
92 | ```javascript
93 | // Example (vanilla JS)
94 | is('+354 000-0000', 'phone:is'); // Returns true
95 | is('000-0000', 'phone:is'); // Returns true
96 | is('0000000', 'phone:is'); // Returns true
97 | ```
98 |
99 | **zip:'two letter ISO 3166 country code' (Zip codes for countries)**
100 |
101 | Argentina (ar)
102 |
103 | Australia (au)
104 |
105 | Austria (at)
106 |
107 | Belgium (be)
108 |
109 | Brazil (br)
110 |
111 | Bulgaria (bg)
112 |
113 | Canada (ca)
114 |
115 | Croatia (hr)
116 |
117 | Cyprus (cy)
118 |
119 | Czech Republic (cz)
120 |
121 | Denmark (dk)
122 |
123 | Estonia (ee)
124 |
125 | Finland (fi)
126 |
127 | France (fr)
128 |
129 | Germany (de)
130 |
131 | Great Britain (gb)
132 |
133 | Greece (gr)
134 |
135 | Hungary (hu)
136 |
137 | Iceland (is)
138 |
139 | Italy (it)
140 |
141 | Japan (jp)
142 |
143 | Latvia (lv)
144 |
145 | Lithuania (lt)
146 |
147 | Luxembourg (lu)
148 |
149 | Malta (mt)
150 |
151 | Netherlands (nl)
152 |
153 | Norway (no)
154 |
155 | Poland (pl)
156 |
157 | Portugal (pt)
158 |
159 | Romania (ro)
160 |
161 | Slovakia (sk)
162 |
163 | Slovenia (se)
164 |
165 | Spain (es)
166 |
167 | Sweden (se)
168 |
169 | Turkey (tr)
170 |
171 | Ukraine (ua)
172 |
173 | United States of America (us)
174 |
175 |
176 | ```javascript
177 | // Example (vanilla JS)
178 | is('112', 'zip:is'); // Returns true
179 | is('32044', 'zip:us'); // Returns true
180 | ```
181 |
182 | ## Additional Goodies
183 |
184 | The second parameter can point to a function within the `check.fn` object. It can also be a regular user defined function accepting a single argument which can be used for some complex (or simple) validation.
185 |
186 | ```javascript
187 | // Example (vanilla JS)
188 | is(42, function ( num ) {
189 | return num === 20; // returns false
190 | });
191 | ```
192 |
193 | The expression argument can be an actual regular expression.
194 |
195 | ```javascript
196 | // Example (vanilla JS)
197 | is('love', /.+/); // returns true
198 | ```
199 |
200 | ## Change Log
201 |
202 | ### 0.2.1 *AUGUST 3, 2013*
203 |
204 | - Add a Luhn algorithm as a check function. Thanks everyone who pointed out the need for it.
205 |
206 | - Fix the README.
207 |
208 | - Rename the `regex` obj to `check`. It just makes more sense since we now have function tests.
209 |
210 | ### 0.2.0 *JULY 30, 2013*
211 |
212 | - All regular expressions are unit tested.
213 |
214 | - Added functionality to validate via functions. The second argument can now either be a regular function accepting a single argument or a string pointing to a function within the `regex.fn` object.
215 |
216 | - Current functions include: even, odd, regexp, ok and function.
217 |
218 | ### 0.1.2 *JUNE 14, 2013*
219 |
220 | - `phone` has become an object so calling it requires a two letter ISO 3166 country code. For example validating Icelandic phone numbers in vanilla JS is now done thusly: `is('+354 000-0000', 'phone:is')`. In addition a few more countries were added.
221 |
222 | - `cc` - pretty much same thing happend as with the `phone` thing.
223 |
224 | ### 0.1.1 *May 24, 2013*
225 |
226 | - First stable release
227 |
228 | ## Get in touch
229 |
230 | Follow me on twitter [@rthor](http://twitter.com/rthor) or send me a line in an [email](mailto:ragnar.valgeirsson@gmail.com).
231 |
--------------------------------------------------------------------------------
/jquery/README.md:
--------------------------------------------------------------------------------
1 | # is.js jQuery plugin (usage)
2 |
3 | See genaral [usage guide](https://github.com/rthor/isjs/blob/master/README.md) for allowed keywords.
4 |
5 | ```javascript
6 | // Works on pretty much all DOM elements...
7 | $('.email').is('email'); // Returns boolean value...
8 |
9 | // And basic strings!
10 | $.is('john.doe@example.com', 'email'); // Returns true
11 | ```
12 |
13 | ### Contibution
14 |
15 | Feel free to contibute in any way you see fit. Just try to keep the coding style that I've chosen in this project and don't break the code :)
16 |
17 | To run tests make sure you've got [testem](https://github.com/airportyh/testem) installed on your system. Simply run the following command in the terminal to start testing:
18 |
19 | $ testem
20 |
21 | ### Get in touch
22 |
23 | Follow me on twitter [@rthor](http://twitter.com/rthor) or send me a line in an [email](mailto:ragnar.valgeirsson@gmail.comz).
--------------------------------------------------------------------------------
/jquery/jquery.is.js:
--------------------------------------------------------------------------------
1 | /**
2 | * is.js - v0.2.1
3 | * Check your data against regular expressions or known keywords.
4 | * http://github.com/rthor/isjs
5 | *
6 | * Licensed under the MIT license.
7 | * Copyright (c) 2013 Ragnar Þór Valgeirsson (rthor)
8 | * http://rthor.is
9 | */
10 | (function($) {
11 | // What does the is plugin do?
12 | $.is = $.fn.is = function() {
13 | // If nothing is there - then return that.
14 | if ( this.length === 0 ) return this;
15 |
16 | // Declare variables
17 | var deep = false,
18 | expression,
19 | check,
20 | value;
21 |
22 | // If plugin is run on the root jQuery object
23 | // Set up appropriate variables
24 | if (arguments.length === 2) {
25 | value = arguments[0];
26 | expression = arguments[1];
27 |
28 | // Else if the plugin is run on an DOM element
29 | // Set up the correct expression and value based on
30 | // node type.
31 | } else {
32 | var nodeName = this[0].nodeName.toLowerCase();
33 | expression = arguments[0];
34 |
35 | value = nodeName === 'input' ?
36 | this.val() :
37 | nodeName === 'p' || nodeName === 'h1' || nodeName === 'h2' || nodeName === 'h3' || nodeName === 'h4' || nodeName === 'h5' || nodeName === 'h6' || nodeName === 'a' || nodeName === 'li' || nodeName === 'blockquote' || nodeName === 'pre' || nodeName === 'code' || nodeName === 'b' || nodeName === 'strong' || nodeName === 'em' || nodeName === 'i' || nodeName === 'div' || nodeName === 'button' || nodeName === 'textarea' || nodeName === 'span' ?
38 | this.html() :
39 | this.selector;
40 | }
41 |
42 | // If expression is deep
43 | if (
44 | typeof expression === 'string' &&
45 | expression.indexOf(':') !== -1
46 | ) {
47 | // Set approriate variables
48 | expression = expression.match( /(\w+)(?:\:)(\w+)/ );
49 | deep = expression[2];
50 | expression = expression[1];
51 | }
52 |
53 | // All regexes that can be tested against.
54 | check = {
55 | cc: {
56 | 'any': /^[0-9]{15,16}$/,
57 | 'AmericanExpress': /^(34)|(37)\d{14}$/,
58 | 'Discover': /^6011\d{12}$/,
59 | 'MasterCard': /^5[1-5]\d{14}$/,
60 | 'Visa': /^4\d{15}$/
61 | },
62 | datetime: /^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,
63 | email: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
64 | isbn: /^(?:(?=.{17}$)97[89][ -](?:[0-9]+[ -]){2}[0-9]+[ -][0-9]|97[89][0-9]{10}|(?=.{13}$)(?:[0-9]+[ -]){2}[0-9]+[ -][0-9Xx]|[0-9]{9}[0-9Xx])$/,
65 | latlng: /-?\d{1,3}\.\d+/,
66 | phone: {
67 | 'ar': /^(?:\+|[0]{2})?(54)?(:?[\s-])*\d{4}(:?[\s-])*\d{4}$/,
68 | 'au': /^(?:\+|0)?(?:61)?\s?[2-478](?:[ -]?[0-9]){8}$/,
69 | 'fr': /^(?:0|\(?\+33\)?\s?|0033\s?)[1-79](?:[\.\-\s]?\d\d){4}$/,
70 | 'is': /^(?:\+|[0]{2})?(354)?(:?[\s-])*\d{3}(:?[\s-])*\d{4}$/,
71 | 'uk': /^(?:\+|044)?(?:\s+)?\(?(\d{1,5}|\d{4}\s*\d{1,2})\)?\s+|-(\d{1,4}(\s+|-)?\d{1,4}|(\d{6}))\d{6}$/,
72 | 'us': /^(\d{3})(:?[\s\-])*(\d{3})(:?[\s\-])*(\d{4})$/
73 | },
74 | zip: {
75 | 'ar': /^\d{4}$/,
76 | 'au': /^\d{4}$/,
77 | 'at': /^\d{4}$/,
78 | 'be': /^\d{4}$/,
79 | 'bg': /^\d{4}$/,
80 | 'br': /^\d{5}[\-]?\d{3}$/,
81 | 'ca': /^[A-Za-z]\d[A-Za-z] \d[A-Za-z]\d$/,
82 | 'cy': /^\d{4}$/,
83 | 'cz': /^\d{3} \d{2}$/,
84 | 'dk': /^\d{3,4}$/,
85 | 'de': /^\d{5}$/,
86 | 'ee': /^\d{5}$/,
87 | 'es': /^((0[1-9]|5[0-2])|[1-4]\d)\d{3}$/,
88 | 'fi': /^\d{5}$/,
89 | 'fr': /^\d{5}$/,
90 | 'gb': /^[A-Za-z]{1,2}[0-9Rr][0-9A-Za-z]? \d[ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}$/,
91 | 'gr': /^\d{3} \d{2}$/,
92 | 'hu': /^\d{4}$/,
93 | 'hr': /^\d{5}$/,
94 | 'is': /^\d{3}$/,
95 | 'it': /^\d{5}$/,
96 | 'jp': /^\d{3}-\d{4}$/,
97 | 'lt': /^(LT-)?\d{5}$/,
98 | 'lu': /^(L\s*(-|—|–))\s*?[\d]{4}$/,
99 | 'lv': /^LV-\d{4}$/,
100 | 'mt': /^[A-Za-z]{3} \d{4}/,
101 | 'nl': /^[1-9]\d{3}\s?[a-zA-Z]{2}$/,
102 | 'no': /^\d{4}$/,
103 | 'pl': /^\d{2}\-\d{3}$/,
104 | 'pt': /^\d{4}$/,
105 | 'ro': /^\d{6}$/,
106 | 'se': /^\d{3}\s?\d{2}$/,
107 | 'si': /^\d{4}$/,
108 | 'sk': /^(SK-)?\d{3} \d{2}$/,
109 | 'tr': /^\d{5}$/,
110 | 'ua': /^\d{5}$/,
111 | 'us': /^(\d{5}([\-]\d{4})?)$/
112 | }
113 | };
114 |
115 | // Function object
116 | check.fn = {
117 | even: function ( num ) {
118 | if ( isNaN( num ) ) num = num.parseInt( num, 10 );
119 | return isNaN( num ) ? false : num === 0 || ( num % 2 ) === 0;
120 | },
121 | function: function ( val ) {
122 | return typeof val === 'function';
123 | },
124 | luhn: function ( num ) {
125 | // Stringify the num
126 | // Create an array and reverse it
127 | num = (num + '').split('').reverse();
128 |
129 | // Define variables for later use
130 | var sum = 0, i, digit;
131 |
132 | for( i = 0; i < num.length; i++) {
133 | // Assign number to digit and multiply by 2 every odd num
134 | digit = parseInt(num[ i ], 10) * ((i + 1) % 2 ? 1 : 2);
135 |
136 | // Add to the sum but reduce by 9 if digit > 9
137 | sum += digit > 9 ? digit - 9 : digit;
138 | }
139 |
140 | // Return boolean
141 | return (sum % 10) === 0;
142 | },
143 | odd: function ( num ) {
144 | return !this.even( num );
145 | },
146 | ok: function ( val, expression ) {
147 | if ( typeof val === 'string' ) {
148 | return expression.test( val.trim() );
149 | } else {
150 | return !!val;
151 | }
152 | },
153 | regexp: function ( val ) {
154 | return val ? (typeof val === 'object' && toString.call(val) === '[object RegExp]') : false;
155 | }
156 | };
157 |
158 | // Return boolean based on expression type
159 | return check.fn.regexp(expression) ?
160 | check.fn.ok(value, expression) :
161 | check.hasOwnProperty(expression) ?
162 | check.fn.ok(value, deep ? check[expression][deep] : check[expression]) :
163 | check.fn.hasOwnProperty( expression ) ?
164 | ( check.fn[ expression ]( value ) ? true : false ) :
165 | check.fn.function( expression ) ?
166 | ( expression( value ) ? true : false ) :
167 | false;
168 |
169 | };
170 |
171 | })(jQuery);
--------------------------------------------------------------------------------
/jquery/jquery.is.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * is.js - v0.2.1
3 | * Check your data against regular expressions or known keywords.
4 | * http://github.com/rthor/isjs
5 | *
6 | * Licensed under the MIT license.
7 | * Copyright (c) 2013 Ragnar Þór Valgeirsson (rthor)
8 | * http://rthor.is
9 | */
10 | !function(a){a.is=a.fn.is=function(){if(0===this.length)return this;var a,b,c,d=!1;if(2===arguments.length)c=arguments[0],a=arguments[1];else{var e=this[0].nodeName.toLowerCase();a=arguments[0],c="input"===e?this.val():"p"===e||"h1"===e||"h2"===e||"h3"===e||"h4"===e||"h5"===e||"h6"===e||"a"===e||"li"===e||"blockquote"===e||"pre"===e||"code"===e||"b"===e||"strong"===e||"em"===e||"i"===e||"div"===e||"button"===e||"textarea"===e||"span"===e?this.html():this.selector}return"string"==typeof a&&-1!==a.indexOf(":")&&(a=a.match(/(\w+)(?:\:)(\w+)/),d=a[2],a=a[1]),b={cc:{any:/^[0-9]{15,16}$/,AmericanExpress:/^(34)|(37)\d{14}$/,Discover:/^6011\d{12}$/,MasterCard:/^5[1-5]\d{14}$/,Visa:/^4\d{15}$/},datetime:/^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,email:/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,isbn:/^(?:(?=.{17}$)97[89][ -](?:[0-9]+[ -]){2}[0-9]+[ -][0-9]|97[89][0-9]{10}|(?=.{13}$)(?:[0-9]+[ -]){2}[0-9]+[ -][0-9Xx]|[0-9]{9}[0-9Xx])$/,latlng:/-?\d{1,3}\.\d+/,phone:{ar:/^(?:\+|[0]{2})?(54)?(:?[\s-])*\d{4}(:?[\s-])*\d{4}$/,au:/^(?:\+|0)?(?:61)?\s?[2-478](?:[ -]?[0-9]){8}$/,fr:/^(?:0|\(?\+33\)?\s?|0033\s?)[1-79](?:[\.\-\s]?\d\d){4}$/,is:/^(?:\+|[0]{2})?(354)?(:?[\s-])*\d{3}(:?[\s-])*\d{4}$/,uk:/^(?:\+|044)?(?:\s+)?\(?(\d{1,5}|\d{4}\s*\d{1,2})\)?\s+|-(\d{1,4}(\s+|-)?\d{1,4}|(\d{6}))\d{6}$/,us:/^(\d{3})(:?[\s\-])*(\d{3})(:?[\s\-])*(\d{4})$/},zip:{ar:/^\d{4}$/,au:/^\d{4}$/,at:/^\d{4}$/,be:/^\d{4}$/,bg:/^\d{4}$/,br:/^\d{5}[\-]?\d{3}$/,ca:/^[A-Za-z]\d[A-Za-z] \d[A-Za-z]\d$/,cy:/^\d{4}$/,cz:/^\d{3} \d{2}$/,dk:/^\d{3,4}$/,de:/^\d{5}$/,ee:/^\d{5}$/,es:/^((0[1-9]|5[0-2])|[1-4]\d)\d{3}$/,fi:/^\d{5}$/,fr:/^\d{5}$/,gb:/^[A-Za-z]{1,2}[0-9Rr][0-9A-Za-z]? \d[ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}$/,gr:/^\d{3} \d{2}$/,hu:/^\d{4}$/,hr:/^\d{5}$/,is:/^\d{3}$/,it:/^\d{5}$/,jp:/^\d{3}-\d{4}$/,lt:/^(LT-)?\d{5}$/,lu:/^(L\s*(-|—|–))\s*?[\d]{4}$/,lv:/^LV-\d{4}$/,mt:/^[A-Za-z]{3} \d{4}/,nl:/^[1-9]\d{3}\s?[a-zA-Z]{2}$/,no:/^\d{4}$/,pl:/^\d{2}\-\d{3}$/,pt:/^\d{4}$/,ro:/^\d{6}$/,se:/^\d{3}\s?\d{2}$/,si:/^\d{4}$/,sk:/^(SK-)?\d{3} \d{2}$/,tr:/^\d{5}$/,ua:/^\d{5}$/,us:/^(\d{5}([\-]\d{4})?)$/}},b.fn={even:function(a){return isNaN(a)&&(a=a.parseInt(a,10)),isNaN(a)?!1:0===a||a%2===0},"function":function(a){return"function"==typeof a},luhn:function(a){a=(a+"").split("").reverse();var b,c,d=0;for(b=0;b
t |