bootstrap_validator-rails 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.md +4 -0
  4. data/lib/bootstrap_validator-rails.rb +5 -0
  5. data/lib/bootstrap_validator-rails/engine.rb +6 -0
  6. data/vendor/javascripts/bootstrapValidator.js +1803 -0
  7. data/vendor/javascripts/language/de_DE.js +326 -0
  8. data/vendor/javascripts/language/en_US.js +327 -0
  9. data/vendor/javascripts/language/es_CL.js +326 -0
  10. data/vendor/javascripts/language/hu_HU.js +326 -0
  11. data/vendor/javascripts/language/vi_VN.js +322 -0
  12. data/vendor/javascripts/language/zh_CN.js +326 -0
  13. data/vendor/javascripts/language/zh_TW.js +326 -0
  14. data/vendor/javascripts/validator/base64.js +25 -0
  15. data/vendor/javascripts/validator/between.js +66 -0
  16. data/vendor/javascripts/validator/callback.js +40 -0
  17. data/vendor/javascripts/validator/choice.js +68 -0
  18. data/vendor/javascripts/validator/creditCard.js +103 -0
  19. data/vendor/javascripts/validator/cusip.js +55 -0
  20. data/vendor/javascripts/validator/cvv.js +116 -0
  21. data/vendor/javascripts/validator/date.js +118 -0
  22. data/vendor/javascripts/validator/different.js +41 -0
  23. data/vendor/javascripts/validator/digits.js +24 -0
  24. data/vendor/javascripts/validator/ean.js +40 -0
  25. data/vendor/javascripts/validator/emailAddress.js +31 -0
  26. data/vendor/javascripts/validator/file.js +69 -0
  27. data/vendor/javascripts/validator/greaterThan.js +61 -0
  28. data/vendor/javascripts/validator/grid.js +37 -0
  29. data/vendor/javascripts/validator/hex.js +25 -0
  30. data/vendor/javascripts/validator/hexColor.js +28 -0
  31. data/vendor/javascripts/validator/iban.js +246 -0
  32. data/vendor/javascripts/validator/id.js +815 -0
  33. data/vendor/javascripts/validator/identical.js +40 -0
  34. data/vendor/javascripts/validator/imei.js +44 -0
  35. data/vendor/javascripts/validator/integer.js +28 -0
  36. data/vendor/javascripts/validator/ip.js +48 -0
  37. data/vendor/javascripts/validator/isbn.js +86 -0
  38. data/vendor/javascripts/validator/isin.js +59 -0
  39. data/vendor/javascripts/validator/ismn.js +59 -0
  40. data/vendor/javascripts/validator/issn.js +46 -0
  41. data/vendor/javascripts/validator/lessThan.js +61 -0
  42. data/vendor/javascripts/validator/mac.js +25 -0
  43. data/vendor/javascripts/validator/notEmpty.js +32 -0
  44. data/vendor/javascripts/validator/numeric.js +39 -0
  45. data/vendor/javascripts/validator/phone.js +84 -0
  46. data/vendor/javascripts/validator/regexp.js +42 -0
  47. data/vendor/javascripts/validator/remote.js +70 -0
  48. data/vendor/javascripts/validator/rtn.js +38 -0
  49. data/vendor/javascripts/validator/sedol.js +40 -0
  50. data/vendor/javascripts/validator/siren.js +28 -0
  51. data/vendor/javascripts/validator/siret.js +38 -0
  52. data/vendor/javascripts/validator/step.js +64 -0
  53. data/vendor/javascripts/validator/stringCase.js +36 -0
  54. data/vendor/javascripts/validator/stringLength.js +81 -0
  55. data/vendor/javascripts/validator/uri.js +101 -0
  56. data/vendor/javascripts/validator/uuid.js +46 -0
  57. data/vendor/javascripts/validator/vat.js +1220 -0
  58. data/vendor/javascripts/validator/vin.js +49 -0
  59. data/vendor/javascripts/validator/zipCode.js +162 -0
  60. data/vendor/stylesheets/bootstrapValidator.css +21 -0
  61. metadata +130 -0
@@ -0,0 +1,41 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.different = $.extend($.fn.bootstrapValidator.i18n.different || {}, {
3
+ 'default': 'Please enter a different value'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.different = {
7
+ html5Attributes: {
8
+ message: 'message',
9
+ field: 'field'
10
+ },
11
+
12
+ /**
13
+ * Return true if the input value is different with given field's value
14
+ *
15
+ * @param {BootstrapValidator} validator The validator plugin instance
16
+ * @param {jQuery} $field Field element
17
+ * @param {Object} options Consists of the following key:
18
+ * - field: The name of field that will be used to compare with current one
19
+ * - message: The invalid message
20
+ * @returns {Boolean}
21
+ */
22
+ validate: function(validator, $field, options) {
23
+ var value = $field.val();
24
+ if (value === '') {
25
+ return true;
26
+ }
27
+
28
+ var compareWith = validator.getFieldElements(options.field);
29
+ if (compareWith === null) {
30
+ return true;
31
+ }
32
+
33
+ if (value !== compareWith.val()) {
34
+ validator.updateStatus(options.field, validator.STATUS_VALID, 'different');
35
+ return true;
36
+ } else {
37
+ return false;
38
+ }
39
+ }
40
+ };
41
+ }(window.jQuery));
@@ -0,0 +1,24 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.digits = $.extend($.fn.bootstrapValidator.i18n.digits || {}, {
3
+ 'default': 'Please enter only digits'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.digits = {
7
+ /**
8
+ * Return true if the input value contains digits only
9
+ *
10
+ * @param {BootstrapValidator} validator Validate plugin instance
11
+ * @param {jQuery} $field Field element
12
+ * @param {Object} [options]
13
+ * @returns {Boolean}
14
+ */
15
+ validate: function(validator, $field, options) {
16
+ var value = $field.val();
17
+ if (value === '') {
18
+ return true;
19
+ }
20
+
21
+ return /^\d+$/.test(value);
22
+ }
23
+ };
24
+ }(window.jQuery));
@@ -0,0 +1,40 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.ean = $.extend($.fn.bootstrapValidator.i18n.ean || {}, {
3
+ 'default': 'Please enter a valid EAN number'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.ean = {
7
+ /**
8
+ * Validate EAN (International Article Number)
9
+ * Examples:
10
+ * - Valid: 73513537, 9780471117094, 4006381333931
11
+ * - Invalid: 73513536
12
+ *
13
+ * @see http://en.wikipedia.org/wiki/European_Article_Number
14
+ * @param {BootstrapValidator} validator The validator plugin instance
15
+ * @param {jQuery} $field Field element
16
+ * @param {Object} options Can consist of the following keys:
17
+ * - message: The invalid message
18
+ * @returns {Boolean}
19
+ */
20
+ validate: function(validator, $field, options) {
21
+ var value = $field.val();
22
+ if (value === '') {
23
+ return true;
24
+ }
25
+
26
+ if (!/^(\d{8}|\d{12}|\d{13})$/.test(value)) {
27
+ return false;
28
+ }
29
+
30
+ var length = value.length,
31
+ sum = 0,
32
+ weight = (length === 8) ? [3, 1] : [1, 3];
33
+ for (var i = 0; i < length - 1; i++) {
34
+ sum += parseInt(value.charAt(i), 10) * weight[i % 2];
35
+ }
36
+ sum = (10 - sum % 10) % 10;
37
+ return (sum + '' === value.charAt(length - 1));
38
+ }
39
+ };
40
+ }(window.jQuery));
@@ -0,0 +1,31 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.emailAddress = $.extend($.fn.bootstrapValidator.i18n.emailAddress || {}, {
3
+ 'default': 'Please enter a valid email address'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.emailAddress = {
7
+ enableByHtml5: function($field) {
8
+ return ('email' === $field.attr('type'));
9
+ },
10
+
11
+ /**
12
+ * Return true if and only if the input value is a valid email address
13
+ *
14
+ * @param {BootstrapValidator} validator Validate plugin instance
15
+ * @param {jQuery} $field Field element
16
+ * @param {Object} [options]
17
+ * @returns {Boolean}
18
+ */
19
+ validate: function(validator, $field, options) {
20
+ var value = $field.val();
21
+ if (value === '') {
22
+ return true;
23
+ }
24
+
25
+ // Email address regular expression
26
+ // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
27
+ var emailRegExp = /^(([^<>()[\]\\.,;:\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,}))$/;
28
+ return emailRegExp.test(value);
29
+ }
30
+ };
31
+ }(window.jQuery));
@@ -0,0 +1,69 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.file = $.extend($.fn.bootstrapValidator.i18n.file || {}, {
3
+ 'default': 'Please choose a valid file'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.file = {
7
+ html5Attributes: {
8
+ extension: 'extension',
9
+ maxsize: 'maxSize',
10
+ message: 'message',
11
+ type: 'type'
12
+ },
13
+
14
+ /**
15
+ * Validate upload file. Use HTML 5 API if the browser supports
16
+ *
17
+ * @param {BootstrapValidator} validator The validator plugin instance
18
+ * @param {jQuery} $field Field element
19
+ * @param {Object} options Can consist of the following keys:
20
+ * - extension: The allowed extensions, separated by a comma
21
+ * - maxSize: The maximum size in bytes
22
+ * - message: The invalid message
23
+ * - type: The allowed MIME type, separated by a comma
24
+ * @returns {Boolean}
25
+ */
26
+ validate: function(validator, $field, options) {
27
+ var value = $field.val();
28
+ if (value === '') {
29
+ return true;
30
+ }
31
+
32
+ var ext,
33
+ extensions = options.extension ? options.extension.toLowerCase().split(',') : null,
34
+ types = options.type ? options.type.toLowerCase().split(',') : null,
35
+ html5 = (window.File && window.FileList && window.FileReader);
36
+
37
+ if (html5) {
38
+ // Get FileList instance
39
+ var files = $field.get(0).files,
40
+ total = files.length;
41
+ for (var i = 0; i < total; i++) {
42
+ // Check file size
43
+ if (options.maxSize && files[i].size > parseInt(options.maxSize, 10)) {
44
+ return false;
45
+ }
46
+
47
+ // Check file extension
48
+ ext = files[i].name.substr(files[i].name.lastIndexOf('.') + 1);
49
+ if (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) {
50
+ return false;
51
+ }
52
+
53
+ // Check file type
54
+ if (types && $.inArray(files[i].type.toLowerCase(), types) === -1) {
55
+ return false;
56
+ }
57
+ }
58
+ } else {
59
+ // Check file extension
60
+ ext = value.substr(value.lastIndexOf('.') + 1);
61
+ if (extensions && $.inArray(ext.toLowerCase(), extensions) === -1) {
62
+ return false;
63
+ }
64
+ }
65
+
66
+ return true;
67
+ }
68
+ };
69
+ }(window.jQuery));
@@ -0,0 +1,61 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.greaterThan = $.extend($.fn.bootstrapValidator.i18n.greaterThan || {}, {
3
+ 'default': 'Please enter a value greater than or equal to %s',
4
+ notInclusive: 'Please enter a value greater than %s'
5
+ });
6
+
7
+ $.fn.bootstrapValidator.validators.greaterThan = {
8
+ html5Attributes: {
9
+ message: 'message',
10
+ value: 'value',
11
+ inclusive: 'inclusive'
12
+ },
13
+
14
+ enableByHtml5: function($field) {
15
+ var min = $field.attr('min');
16
+ if (min) {
17
+ return {
18
+ value: min
19
+ };
20
+ }
21
+
22
+ return false;
23
+ },
24
+
25
+ /**
26
+ * Return true if the input value is greater than or equals to given number
27
+ *
28
+ * @param {BootstrapValidator} validator Validate plugin instance
29
+ * @param {jQuery} $field Field element
30
+ * @param {Object} options Can consist of the following keys:
31
+ * - value: Define the number to compare with. It can be
32
+ * - A number
33
+ * - Name of field which its value defines the number
34
+ * - Name of callback function that returns the number
35
+ * - A callback function that returns the number
36
+ *
37
+ * - inclusive [optional]: Can be true or false. Default is true
38
+ * - message: The invalid message
39
+ * @returns {Boolean|Object}
40
+ */
41
+ validate: function(validator, $field, options) {
42
+ var value = $field.val();
43
+ if (value === '') {
44
+ return true;
45
+ }
46
+
47
+ var compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value);
48
+
49
+ value = parseFloat(value);
50
+ return (options.inclusive === true || options.inclusive === undefined)
51
+ ? {
52
+ valid: value >= compareTo,
53
+ message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan['default'], compareTo)
54
+ }
55
+ : {
56
+ valid: value > compareTo,
57
+ message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.greaterThan.notInclusive, compareTo)
58
+ };
59
+ }
60
+ };
61
+ }(window.jQuery));
@@ -0,0 +1,37 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.grid = $.extend($.fn.bootstrapValidator.i18n.grid || {}, {
3
+ 'default': 'Please enter a valid GRId number'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.grid = {
7
+ /**
8
+ * Validate GRId (Global Release Identifier)
9
+ * Examples:
10
+ * - Valid: A12425GABC1234002M, A1-2425G-ABC1234002-M, A1 2425G ABC1234002 M, Grid:A1-2425G-ABC1234002-M
11
+ * - Invalid: A1-2425G-ABC1234002-Q
12
+ *
13
+ * @see http://en.wikipedia.org/wiki/Global_Release_Identifier
14
+ * @param {BootstrapValidator} validator The validator plugin instance
15
+ * @param {jQuery} $field Field element
16
+ * @param {Object} options Can consist of the following keys:
17
+ * - message: The invalid message
18
+ * @returns {Boolean}
19
+ */
20
+ validate: function(validator, $field, options) {
21
+ var value = $field.val();
22
+ if (value === '') {
23
+ return true;
24
+ }
25
+
26
+ value = value.toUpperCase();
27
+ if (!/^[GRID:]*([0-9A-Z]{2})[-\s]*([0-9A-Z]{5})[-\s]*([0-9A-Z]{10})[-\s]*([0-9A-Z]{1})$/g.test(value)) {
28
+ return false;
29
+ }
30
+ value = value.replace(/\s/g, '').replace(/-/g, '');
31
+ if ('GRID:' === value.substr(0, 5)) {
32
+ value = value.substr(5);
33
+ }
34
+ return $.fn.bootstrapValidator.helpers.mod37And36(value);
35
+ }
36
+ };
37
+ }(window.jQuery));
@@ -0,0 +1,25 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.hex = $.extend($.fn.bootstrapValidator.i18n.hex || {}, {
3
+ 'default': 'Please enter a valid hexadecimal number'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.hex = {
7
+ /**
8
+ * Return true if and only if the input value is a valid hexadecimal number
9
+ *
10
+ * @param {BootstrapValidator} validator The validator plugin instance
11
+ * @param {jQuery} $field Field element
12
+ * @param {Object} options Consist of key:
13
+ * - message: The invalid message
14
+ * @returns {Boolean}
15
+ */
16
+ validate: function(validator, $field, options) {
17
+ var value = $field.val();
18
+ if (value === '') {
19
+ return true;
20
+ }
21
+
22
+ return /^[0-9a-fA-F]+$/.test(value);
23
+ }
24
+ };
25
+ }(window.jQuery));
@@ -0,0 +1,28 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.hexColor = $.extend($.fn.bootstrapValidator.i18n.hexColor || {}, {
3
+ 'default': 'Please enter a valid hex color'
4
+ });
5
+
6
+ $.fn.bootstrapValidator.validators.hexColor = {
7
+ enableByHtml5: function($field) {
8
+ return ('color' === $field.attr('type'));
9
+ },
10
+
11
+ /**
12
+ * Return true if the input value is a valid hex color
13
+ *
14
+ * @param {BootstrapValidator} validator The validator plugin instance
15
+ * @param {jQuery} $field Field element
16
+ * @param {Object} options Can consist of the following keys:
17
+ * - message: The invalid message
18
+ * @returns {Boolean}
19
+ */
20
+ validate: function(validator, $field, options) {
21
+ var value = $field.val();
22
+ if (value === '') {
23
+ return true;
24
+ }
25
+ return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
26
+ }
27
+ };
28
+ }(window.jQuery));
@@ -0,0 +1,246 @@
1
+ (function($) {
2
+ $.fn.bootstrapValidator.i18n.iban = $.extend($.fn.bootstrapValidator.i18n.iban || {}, {
3
+ 'default': 'Please enter a valid IBAN number',
4
+ countryNotSupported: 'The country code %s is not supported',
5
+ country: 'Please enter a valid IBAN number in %s',
6
+ countries: {
7
+ AD: 'Andorra',
8
+ AE: 'United Arab Emirates',
9
+ AL: 'Albania',
10
+ AO: 'Angola',
11
+ AT: 'Austria',
12
+ AZ: 'Azerbaijan',
13
+ BA: 'Bosnia and Herzegovina',
14
+ BE: 'Belgium',
15
+ BF: 'Burkina Faso',
16
+ BG: 'Bulgaria',
17
+ BH: 'Bahrain',
18
+ BI: 'Burundi',
19
+ BJ: 'Benin',
20
+ BR: 'Brazil',
21
+ CH: 'Switzerland',
22
+ CI: 'Ivory Coast',
23
+ CM: 'Cameroon',
24
+ CR: 'Costa Rica',
25
+ CV: 'Cape Verde',
26
+ CY: 'Cyprus',
27
+ CZ: 'Czech Republic',
28
+ DE: 'Germany',
29
+ DK: 'Denmark',
30
+ DO: 'Dominican Republic',
31
+ DZ: 'Algeria',
32
+ EE: 'Estonia',
33
+ ES: 'Spain',
34
+ FI: 'Finland',
35
+ FO: 'Faroe Islands',
36
+ FR: 'France',
37
+ GB: 'United Kingdom',
38
+ GE: 'Georgia',
39
+ GI: 'Gibraltar',
40
+ GL: 'Greenland',
41
+ GR: 'Greece',
42
+ GT: 'Guatemala',
43
+ HR: 'Croatia',
44
+ HU: 'Hungary',
45
+ IE: 'Ireland',
46
+ IL: 'Israel',
47
+ IR: 'Iran',
48
+ IS: 'Iceland',
49
+ IT: 'Italy',
50
+ JO: 'Jordan',
51
+ KW: 'Kuwait',
52
+ KZ: 'Kazakhstan',
53
+ LB: 'Lebanon',
54
+ LI: 'Liechtenstein',
55
+ LT: 'Lithuania',
56
+ LU: 'Luxembourg',
57
+ LV: 'Latvia',
58
+ MC: 'Monaco',
59
+ MD: 'Moldova',
60
+ ME: 'Montenegro',
61
+ MG: 'Madagascar',
62
+ MK: 'Macedonia',
63
+ ML: 'Mali',
64
+ MR: 'Mauritania',
65
+ MT: 'Malta',
66
+ MU: 'Mauritius',
67
+ MZ: 'Mozambique',
68
+ NL: 'Netherlands',
69
+ NO: 'Norway',
70
+ PK: 'Pakistan',
71
+ PL: 'Poland',
72
+ PS: 'Palestinian',
73
+ PT: 'Portugal',
74
+ QA: 'Qatar',
75
+ RO: 'Romania',
76
+ RS: 'Serbia',
77
+ SA: 'Saudi Arabia',
78
+ SE: 'Sweden',
79
+ SI: 'Slovenia',
80
+ SK: 'Slovakia',
81
+ SM: 'San Marino',
82
+ SN: 'Senegal',
83
+ TN: 'Tunisia',
84
+ TR: 'Turkey',
85
+ VG: 'Virgin Islands, British'
86
+ }
87
+ });
88
+
89
+ $.fn.bootstrapValidator.validators.iban = {
90
+ html5Attributes: {
91
+ message: 'message',
92
+ country: 'country'
93
+ },
94
+
95
+ // http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
96
+ // http://en.wikipedia.org/wiki/International_Bank_Account_Number#IBAN_formats_by_country
97
+ REGEX: {
98
+ 'AD': 'AD[0-9]{2}[0-9]{4}[0-9]{4}[A-Z0-9]{12}', // Andorra
99
+ 'AE': 'AE[0-9]{2}[0-9]{3}[0-9]{16}', // United Arab Emirates
100
+ 'AL': 'AL[0-9]{2}[0-9]{8}[A-Z0-9]{16}', // Albania
101
+ 'AO': 'AO[0-9]{2}[0-9]{21}', // Angola
102
+ 'AT': 'AT[0-9]{2}[0-9]{5}[0-9]{11}', // Austria
103
+ 'AZ': 'AZ[0-9]{2}[A-Z]{4}[A-Z0-9]{20}', // Azerbaijan
104
+ 'BA': 'BA[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{8}[0-9]{2}', // Bosnia and Herzegovina
105
+ 'BE': 'BE[0-9]{2}[0-9]{3}[0-9]{7}[0-9]{2}', // Belgium
106
+ 'BF': 'BF[0-9]{2}[0-9]{23}', // Burkina Faso
107
+ 'BG': 'BG[0-9]{2}[A-Z]{4}[0-9]{4}[0-9]{2}[A-Z0-9]{8}', // Bulgaria
108
+ 'BH': 'BH[0-9]{2}[A-Z]{4}[A-Z0-9]{14}', // Bahrain
109
+ 'BI': 'BI[0-9]{2}[0-9]{12}', // Burundi
110
+ 'BJ': 'BJ[0-9]{2}[A-Z]{1}[0-9]{23}', // Benin
111
+ 'BR': 'BR[0-9]{2}[0-9]{8}[0-9]{5}[0-9]{10}[A-Z][A-Z0-9]', // Brazil
112
+ 'CH': 'CH[0-9]{2}[0-9]{5}[A-Z0-9]{12}', // Switzerland
113
+ 'CI': 'CI[0-9]{2}[A-Z]{1}[0-9]{23}', // Ivory Coast
114
+ 'CM': 'CM[0-9]{2}[0-9]{23}', // Cameroon
115
+ 'CR': 'CR[0-9]{2}[0-9]{3}[0-9]{14}', // Costa Rica
116
+ 'CV': 'CV[0-9]{2}[0-9]{21}', // Cape Verde
117
+ 'CY': 'CY[0-9]{2}[0-9]{3}[0-9]{5}[A-Z0-9]{16}', // Cyprus
118
+ 'CZ': 'CZ[0-9]{2}[0-9]{20}', // Czech Republic
119
+ 'DE': 'DE[0-9]{2}[0-9]{8}[0-9]{10}', // Germany
120
+ 'DK': 'DK[0-9]{2}[0-9]{14}', // Denmark
121
+ 'DO': 'DO[0-9]{2}[A-Z0-9]{4}[0-9]{20}', // Dominican Republic
122
+ 'DZ': 'DZ[0-9]{2}[0-9]{20}', // Algeria
123
+ 'EE': 'EE[0-9]{2}[0-9]{2}[0-9]{2}[0-9]{11}[0-9]{1}', // Estonia
124
+ 'ES': 'ES[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{1}[0-9]{1}[0-9]{10}', // Spain
125
+ 'FI': 'FI[0-9]{2}[0-9]{6}[0-9]{7}[0-9]{1}', // Finland
126
+ 'FO': 'FO[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}', // Faroe Islands
127
+ 'FR': 'FR[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}', // France
128
+ 'GB': 'GB[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}', // United Kingdom
129
+ 'GE': 'GE[0-9]{2}[A-Z]{2}[0-9]{16}', // Georgia
130
+ 'GI': 'GI[0-9]{2}[A-Z]{4}[A-Z0-9]{15}', // Gibraltar
131
+ 'GL': 'GL[0-9]{2}[0-9]{4}[0-9]{9}[0-9]{1}', // Greenland
132
+ 'GR': 'GR[0-9]{2}[0-9]{3}[0-9]{4}[A-Z0-9]{16}', // Greece
133
+ 'GT': 'GT[0-9]{2}[A-Z0-9]{4}[A-Z0-9]{20}', // Guatemala
134
+ 'HR': 'HR[0-9]{2}[0-9]{7}[0-9]{10}', // Croatia
135
+ 'HU': 'HU[0-9]{2}[0-9]{3}[0-9]{4}[0-9]{1}[0-9]{15}[0-9]{1}', // Hungary
136
+ 'IE': 'IE[0-9]{2}[A-Z]{4}[0-9]{6}[0-9]{8}', // Ireland
137
+ 'IL': 'IL[0-9]{2}[0-9]{3}[0-9]{3}[0-9]{13}', // Israel
138
+ 'IR': 'IR[0-9]{2}[0-9]{22}', // Iran
139
+ 'IS': 'IS[0-9]{2}[0-9]{4}[0-9]{2}[0-9]{6}[0-9]{10}', // Iceland
140
+ 'IT': 'IT[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', // Italy
141
+ 'JO': 'JO[0-9]{2}[A-Z]{4}[0-9]{4}[0]{8}[A-Z0-9]{10}', // Jordan
142
+ 'KW': 'KW[0-9]{2}[A-Z]{4}[0-9]{22}', // Kuwait
143
+ 'KZ': 'KZ[0-9]{2}[0-9]{3}[A-Z0-9]{13}', // Kazakhstan
144
+ 'LB': 'LB[0-9]{2}[0-9]{4}[A-Z0-9]{20}', // Lebanon
145
+ 'LI': 'LI[0-9]{2}[0-9]{5}[A-Z0-9]{12}', // Liechtenstein
146
+ 'LT': 'LT[0-9]{2}[0-9]{5}[0-9]{11}', // Lithuania
147
+ 'LU': 'LU[0-9]{2}[0-9]{3}[A-Z0-9]{13}', // Luxembourg
148
+ 'LV': 'LV[0-9]{2}[A-Z]{4}[A-Z0-9]{13}', // Latvia
149
+ 'MC': 'MC[0-9]{2}[0-9]{5}[0-9]{5}[A-Z0-9]{11}[0-9]{2}', // Monaco
150
+ 'MD': 'MD[0-9]{2}[A-Z0-9]{20}', // Moldova
151
+ 'ME': 'ME[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Montenegro
152
+ 'MG': 'MG[0-9]{2}[0-9]{23}', // Madagascar
153
+ 'MK': 'MK[0-9]{2}[0-9]{3}[A-Z0-9]{10}[0-9]{2}', // Macedonia
154
+ 'ML': 'ML[0-9]{2}[A-Z]{1}[0-9]{23}', // Mali
155
+ 'MR': 'MR13[0-9]{5}[0-9]{5}[0-9]{11}[0-9]{2}', // Mauritania
156
+ 'MT': 'MT[0-9]{2}[A-Z]{4}[0-9]{5}[A-Z0-9]{18}', // Malta
157
+ 'MU': 'MU[0-9]{2}[A-Z]{4}[0-9]{2}[0-9]{2}[0-9]{12}[0-9]{3}[A-Z]{3}',// Mauritius
158
+ 'MZ': 'MZ[0-9]{2}[0-9]{21}', // Mozambique
159
+ 'NL': 'NL[0-9]{2}[A-Z]{4}[0-9]{10}', // Netherlands
160
+ 'NO': 'NO[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{1}', // Norway
161
+ 'PK': 'PK[0-9]{2}[A-Z]{4}[A-Z0-9]{16}', // Pakistan
162
+ 'PL': 'PL[0-9]{2}[0-9]{8}[0-9]{16}', // Poland
163
+ 'PS': 'PS[0-9]{2}[A-Z]{4}[A-Z0-9]{21}', // Palestinian
164
+ 'PT': 'PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}', // Portugal
165
+ 'QA': 'QA[0-9]{2}[A-Z]{4}[A-Z0-9]{21}', // Qatar
166
+ 'RO': 'RO[0-9]{2}[A-Z]{4}[A-Z0-9]{16}', // Romania
167
+ 'RS': 'RS[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Serbia
168
+ 'SA': 'SA[0-9]{2}[0-9]{2}[A-Z0-9]{18}', // Saudi Arabia
169
+ 'SE': 'SE[0-9]{2}[0-9]{3}[0-9]{16}[0-9]{1}', // Sweden
170
+ 'SI': 'SI[0-9]{2}[0-9]{5}[0-9]{8}[0-9]{2}', // Slovenia
171
+ 'SK': 'SK[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}', // Slovakia
172
+ 'SM': 'SM[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', // San Marino
173
+ 'SN': 'SN[0-9]{2}[A-Z]{1}[0-9]{23}', // Senegal
174
+ 'TN': 'TN59[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Tunisia
175
+ 'TR': 'TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}', // Turkey
176
+ 'VG': 'VG[0-9]{2}[A-Z]{4}[0-9]{16}' // Virgin Islands, British
177
+ },
178
+
179
+ /**
180
+ * Validate an International Bank Account Number (IBAN)
181
+ * To test it, take the sample IBAN from
182
+ * http://www.nordea.com/Our+services/International+products+and+services/Cash+Management/IBAN+countries/908462.html
183
+ *
184
+ * @param {BootstrapValidator} validator The validator plugin instance
185
+ * @param {jQuery} $field Field element
186
+ * @param {Object} options Can consist of the following keys:
187
+ * - message: The invalid message
188
+ * - country: The ISO 3166-1 country code. It can be
189
+ * - A country code
190
+ * - Name of field which its value defines the country code
191
+ * - Name of callback function that returns the country code
192
+ * - A callback function that returns the country code
193
+ * @returns {Boolean|Object}
194
+ */
195
+ validate: function(validator, $field, options) {
196
+ var value = $field.val();
197
+ if (value === '') {
198
+ return true;
199
+ }
200
+
201
+ value = value.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
202
+ var country = options.country;
203
+ if (!country) {
204
+ country = value.substr(0, 2);
205
+ } else if (typeof country !== 'string' || !this.REGEX[country]) {
206
+ // Determine the country code
207
+ country = validator.getDynamicOption($field, country);
208
+ }
209
+
210
+ if (!this.REGEX[country]) {
211
+ return {
212
+ valid: false,
213
+ message: $.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.iban.countryNotSupported, country)
214
+ };
215
+ }
216
+
217
+ if (!(new RegExp('^' + this.REGEX[country] + '$')).test(value)) {
218
+ return {
219
+ valid: false,
220
+ message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.iban.country, $.fn.bootstrapValidator.i18n.iban.countries[country])
221
+ };
222
+ }
223
+
224
+ value = value.substr(4) + value.substr(0, 4);
225
+ value = $.map(value.split(''), function(n) {
226
+ var code = n.charCodeAt(0);
227
+ return (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0))
228
+ // Replace A, B, C, ..., Z with 10, 11, ..., 35
229
+ ? (code - 'A'.charCodeAt(0) + 10)
230
+ : n;
231
+ });
232
+ value = value.join('');
233
+
234
+ var temp = parseInt(value.substr(0, 1), 10),
235
+ length = value.length;
236
+ for (var i = 1; i < length; ++i) {
237
+ temp = (temp * 10 + parseInt(value.substr(i, 1), 10)) % 97;
238
+ }
239
+
240
+ return {
241
+ valid: (temp === 1),
242
+ message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.iban.country, $.fn.bootstrapValidator.i18n.iban.countries[country])
243
+ };
244
+ }
245
+ };
246
+ }(window.jQuery));