bootstrap_validator_rails 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/lib/bootstrap_validator_rails/version.rb +1 -1
- data/vendor/assets/javascripts/bootstrapValidator.js +4677 -2
- data/vendor/assets/javascripts/bootstrapValidator.min.js +12 -0
- data/vendor/assets/stylesheets/bootstrapValidator.min.css +11 -0
- metadata +4 -48
- data/vendor/assets/javascripts/validator/base64.js +0 -25
- data/vendor/assets/javascripts/validator/between.js +0 -66
- data/vendor/assets/javascripts/validator/callback.js +0 -40
- data/vendor/assets/javascripts/validator/choice.js +0 -68
- data/vendor/assets/javascripts/validator/creditCard.js +0 -103
- data/vendor/assets/javascripts/validator/cusip.js +0 -55
- data/vendor/assets/javascripts/validator/cvv.js +0 -116
- data/vendor/assets/javascripts/validator/date.js +0 -118
- data/vendor/assets/javascripts/validator/different.js +0 -41
- data/vendor/assets/javascripts/validator/digits.js +0 -24
- data/vendor/assets/javascripts/validator/ean.js +0 -40
- data/vendor/assets/javascripts/validator/emailAddress.js +0 -31
- data/vendor/assets/javascripts/validator/file.js +0 -69
- data/vendor/assets/javascripts/validator/greaterThan.js +0 -61
- data/vendor/assets/javascripts/validator/grid.js +0 -37
- data/vendor/assets/javascripts/validator/hex.js +0 -25
- data/vendor/assets/javascripts/validator/hexColor.js +0 -28
- data/vendor/assets/javascripts/validator/iban.js +0 -246
- data/vendor/assets/javascripts/validator/id.js +0 -815
- data/vendor/assets/javascripts/validator/identical.js +0 -40
- data/vendor/assets/javascripts/validator/imei.js +0 -44
- data/vendor/assets/javascripts/validator/integer.js +0 -28
- data/vendor/assets/javascripts/validator/ip.js +0 -48
- data/vendor/assets/javascripts/validator/isbn.js +0 -86
- data/vendor/assets/javascripts/validator/isin.js +0 -59
- data/vendor/assets/javascripts/validator/ismn.js +0 -59
- data/vendor/assets/javascripts/validator/issn.js +0 -46
- data/vendor/assets/javascripts/validator/lessThan.js +0 -61
- data/vendor/assets/javascripts/validator/mac.js +0 -25
- data/vendor/assets/javascripts/validator/notEmpty.js +0 -32
- data/vendor/assets/javascripts/validator/numeric.js +0 -39
- data/vendor/assets/javascripts/validator/phone.js +0 -84
- data/vendor/assets/javascripts/validator/regexp.js +0 -42
- data/vendor/assets/javascripts/validator/remote.js +0 -70
- data/vendor/assets/javascripts/validator/rtn.js +0 -38
- data/vendor/assets/javascripts/validator/sedol.js +0 -40
- data/vendor/assets/javascripts/validator/siren.js +0 -28
- data/vendor/assets/javascripts/validator/siret.js +0 -38
- data/vendor/assets/javascripts/validator/step.js +0 -64
- data/vendor/assets/javascripts/validator/stringCase.js +0 -36
- data/vendor/assets/javascripts/validator/stringLength.js +0 -81
- data/vendor/assets/javascripts/validator/uri.js +0 -101
- data/vendor/assets/javascripts/validator/uuid.js +0 -46
- data/vendor/assets/javascripts/validator/vat.js +0 -1220
- data/vendor/assets/javascripts/validator/vin.js +0 -49
- data/vendor/assets/javascripts/validator/zipCode.js +0 -162
@@ -1,61 +0,0 @@
|
|
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));
|
@@ -1,37 +0,0 @@
|
|
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));
|
@@ -1,25 +0,0 @@
|
|
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));
|
@@ -1,28 +0,0 @@
|
|
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));
|
@@ -1,246 +0,0 @@
|
|
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));
|
@@ -1,815 +0,0 @@
|
|
1
|
-
(function($) {
|
2
|
-
$.fn.bootstrapValidator.i18n.id = $.extend($.fn.bootstrapValidator.i18n.id || {}, {
|
3
|
-
'default': 'Please enter a valid identification number',
|
4
|
-
countryNotSupported: 'The country code %s is not supported',
|
5
|
-
country: 'Please enter a valid %s identification number',
|
6
|
-
countries: {
|
7
|
-
BA: 'Bosnia and Herzegovina',
|
8
|
-
BG: 'Bulgarian',
|
9
|
-
BR: 'Brazilian',
|
10
|
-
CH: 'Swiss',
|
11
|
-
CL: 'Chilean',
|
12
|
-
CZ: 'Czech',
|
13
|
-
DK: 'Danish',
|
14
|
-
EE: 'Estonian',
|
15
|
-
ES: 'Spanish',
|
16
|
-
FI: 'Finnish',
|
17
|
-
HR: 'Croatian',
|
18
|
-
IE: 'Irish',
|
19
|
-
IS: 'Iceland',
|
20
|
-
LT: 'Lithuanian',
|
21
|
-
LV: 'Latvian',
|
22
|
-
ME: 'Montenegro',
|
23
|
-
MK: 'Macedonian',
|
24
|
-
NL: 'Dutch',
|
25
|
-
RO: 'Romanian',
|
26
|
-
RS: 'Serbian',
|
27
|
-
SE: 'Swedish',
|
28
|
-
SI: 'Slovenian',
|
29
|
-
SK: 'Slovak',
|
30
|
-
SM: 'San Marino',
|
31
|
-
ZA: 'South African'
|
32
|
-
}
|
33
|
-
});
|
34
|
-
|
35
|
-
$.fn.bootstrapValidator.validators.id = {
|
36
|
-
html5Attributes: {
|
37
|
-
message: 'message',
|
38
|
-
country: 'country'
|
39
|
-
},
|
40
|
-
|
41
|
-
// Supported country codes
|
42
|
-
COUNTRY_CODES: [
|
43
|
-
'BA', 'BG', 'BR', 'CH', 'CL', 'CZ', 'DK', 'EE', 'ES', 'FI', 'HR', 'IE', 'IS', 'LT', 'LV', 'ME', 'MK', 'NL',
|
44
|
-
'RO', 'RS', 'SE', 'SI', 'SK', 'SM', 'ZA'
|
45
|
-
],
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Validate identification number in different countries
|
49
|
-
*
|
50
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number
|
51
|
-
* @param {BootstrapValidator} validator The validator plugin instance
|
52
|
-
* @param {jQuery} $field Field element
|
53
|
-
* @param {Object} options Consist of key:
|
54
|
-
* - message: The invalid message
|
55
|
-
* - country: The ISO 3166-1 country code. It can be
|
56
|
-
* - One of country code defined in COUNTRY_CODES
|
57
|
-
* - Name of field which its value defines the country code
|
58
|
-
* - Name of callback function that returns the country code
|
59
|
-
* - A callback function that returns the country code
|
60
|
-
* @returns {Boolean|Object}
|
61
|
-
*/
|
62
|
-
validate: function(validator, $field, options) {
|
63
|
-
var value = $field.val();
|
64
|
-
if (value === '') {
|
65
|
-
return true;
|
66
|
-
}
|
67
|
-
|
68
|
-
var country = options.country;
|
69
|
-
if (!country) {
|
70
|
-
country = value.substr(0, 2);
|
71
|
-
} else if (typeof country !== 'string' || $.inArray(country.toUpperCase(), this.COUNTRY_CODES) === -1) {
|
72
|
-
// Determine the country code
|
73
|
-
country = validator.getDynamicOption($field, country);
|
74
|
-
}
|
75
|
-
|
76
|
-
if ($.inArray(country, this.COUNTRY_CODES) === -1) {
|
77
|
-
return { valid: false, message: $.fn.bootstrapValidator.helpers.format($.fn.bootstrapValidator.i18n.id.countryNotSupported, country) };
|
78
|
-
}
|
79
|
-
|
80
|
-
var method = ['_', country.toLowerCase()].join('');
|
81
|
-
return this[method](value)
|
82
|
-
? true
|
83
|
-
: {
|
84
|
-
valid: false,
|
85
|
-
message: $.fn.bootstrapValidator.helpers.format(options.message || $.fn.bootstrapValidator.i18n.id.country, $.fn.bootstrapValidator.i18n.id.countries[country.toUpperCase()])
|
86
|
-
};
|
87
|
-
},
|
88
|
-
|
89
|
-
/**
|
90
|
-
* Validate Unique Master Citizen Number which uses in
|
91
|
-
* - Bosnia and Herzegovina (country code: BA)
|
92
|
-
* - Macedonia (MK)
|
93
|
-
* - Montenegro (ME)
|
94
|
-
* - Serbia (RS)
|
95
|
-
* - Slovenia (SI)
|
96
|
-
*
|
97
|
-
* @see http://en.wikipedia.org/wiki/Unique_Master_Citizen_Number
|
98
|
-
* @param {String} value The ID
|
99
|
-
* @param {String} countryCode The ISO country code, can be BA, MK, ME, RS, SI
|
100
|
-
* @returns {Boolean}
|
101
|
-
*/
|
102
|
-
_validateJMBG: function(value, countryCode) {
|
103
|
-
if (!/^\d{13}$/.test(value)) {
|
104
|
-
return false;
|
105
|
-
}
|
106
|
-
var day = parseInt(value.substr(0, 2), 10),
|
107
|
-
month = parseInt(value.substr(2, 2), 10),
|
108
|
-
year = parseInt(value.substr(4, 3), 10),
|
109
|
-
rr = parseInt(value.substr(7, 2), 10),
|
110
|
-
k = parseInt(value.substr(12, 1), 10);
|
111
|
-
|
112
|
-
// Validate date of birth
|
113
|
-
// FIXME: Validate the year of birth
|
114
|
-
if (day > 31 || month > 12) {
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
|
118
|
-
// Validate checksum
|
119
|
-
var sum = 0;
|
120
|
-
for (var i = 0; i < 6; i++) {
|
121
|
-
sum += (7 - i) * (parseInt(value.charAt(i), 10) + parseInt(value.charAt(i + 6), 10));
|
122
|
-
}
|
123
|
-
sum = 11 - sum % 11;
|
124
|
-
if (sum === 10 || sum === 11) {
|
125
|
-
sum = 0;
|
126
|
-
}
|
127
|
-
if (sum !== k) {
|
128
|
-
return false;
|
129
|
-
}
|
130
|
-
|
131
|
-
// Validate political region
|
132
|
-
// rr is the political region of birth, which can be in ranges:
|
133
|
-
// 10-19: Bosnia and Herzegovina
|
134
|
-
// 20-29: Montenegro
|
135
|
-
// 30-39: Croatia (not used anymore)
|
136
|
-
// 41-49: Macedonia
|
137
|
-
// 50-59: Slovenia (only 50 is used)
|
138
|
-
// 70-79: Central Serbia
|
139
|
-
// 80-89: Serbian province of Vojvodina
|
140
|
-
// 90-99: Kosovo
|
141
|
-
switch (countryCode.toUpperCase()) {
|
142
|
-
case 'BA':
|
143
|
-
return (10 <= rr && rr <= 19);
|
144
|
-
case 'MK':
|
145
|
-
return (41 <= rr && rr <= 49);
|
146
|
-
case 'ME':
|
147
|
-
return (20 <= rr && rr <= 29);
|
148
|
-
case 'RS':
|
149
|
-
return (70 <= rr && rr <= 99);
|
150
|
-
case 'SI':
|
151
|
-
return (50 <= rr && rr <= 59);
|
152
|
-
default:
|
153
|
-
return true;
|
154
|
-
}
|
155
|
-
},
|
156
|
-
|
157
|
-
_ba: function(value) {
|
158
|
-
return this._validateJMBG(value, 'BA');
|
159
|
-
},
|
160
|
-
_mk: function(value) {
|
161
|
-
return this._validateJMBG(value, 'MK');
|
162
|
-
},
|
163
|
-
_me: function(value) {
|
164
|
-
return this._validateJMBG(value, 'ME');
|
165
|
-
},
|
166
|
-
_rs: function(value) {
|
167
|
-
return this._validateJMBG(value, 'RS');
|
168
|
-
},
|
169
|
-
|
170
|
-
/**
|
171
|
-
* Examples: 0101006500006
|
172
|
-
*/
|
173
|
-
_si: function(value) {
|
174
|
-
return this._validateJMBG(value, 'SI');
|
175
|
-
},
|
176
|
-
|
177
|
-
/**
|
178
|
-
* Validate Bulgarian national identification number (EGN)
|
179
|
-
* Examples:
|
180
|
-
* - Valid: 7523169263, 8032056031, 803205 603 1, 8001010008, 7501020018, 7552010005, 7542011030
|
181
|
-
* - Invalid: 8019010008
|
182
|
-
*
|
183
|
-
* @see http://en.wikipedia.org/wiki/Uniform_civil_number
|
184
|
-
* @param {String} value The ID
|
185
|
-
* @returns {Boolean}
|
186
|
-
*/
|
187
|
-
_bg: function(value) {
|
188
|
-
if (!/^\d{10}$/.test(value) && !/^\d{6}\s\d{3}\s\d{1}$/.test(value)) {
|
189
|
-
return false;
|
190
|
-
}
|
191
|
-
value = value.replace(/\s/g, '');
|
192
|
-
// Check the birth date
|
193
|
-
var year = parseInt(value.substr(0, 2), 10) + 1900,
|
194
|
-
month = parseInt(value.substr(2, 2), 10),
|
195
|
-
day = parseInt(value.substr(4, 2), 10);
|
196
|
-
if (month > 40) {
|
197
|
-
year += 100;
|
198
|
-
month -= 40;
|
199
|
-
} else if (month > 20) {
|
200
|
-
year -= 100;
|
201
|
-
month -= 20;
|
202
|
-
}
|
203
|
-
|
204
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
|
205
|
-
return false;
|
206
|
-
}
|
207
|
-
|
208
|
-
var sum = 0,
|
209
|
-
weight = [2, 4, 8, 5, 10, 9, 7, 3, 6];
|
210
|
-
for (var i = 0; i < 9; i++) {
|
211
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
212
|
-
}
|
213
|
-
sum = (sum % 11) % 10;
|
214
|
-
return (sum + '' === value.substr(9, 1));
|
215
|
-
},
|
216
|
-
|
217
|
-
/**
|
218
|
-
* Validate Brazilian national identification number (CPF)
|
219
|
-
* Examples:
|
220
|
-
* - Valid: 39053344705, 390.533.447-05, 111.444.777-35
|
221
|
-
* - Invalid: 231.002.999-00
|
222
|
-
*
|
223
|
-
* @see http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas
|
224
|
-
* @param {String} value The ID
|
225
|
-
* @returns {Boolean}
|
226
|
-
*/
|
227
|
-
_br: function(value) {
|
228
|
-
if (/^1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11}|0{11}$/.test(value)) {
|
229
|
-
return false;
|
230
|
-
}
|
231
|
-
if (!/^\d{11}$/.test(value) && !/^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(value)) {
|
232
|
-
return false;
|
233
|
-
}
|
234
|
-
value = value.replace(/\./g, '').replace(/-/g, '');
|
235
|
-
|
236
|
-
var d1 = 0;
|
237
|
-
for (var i = 0; i < 9; i++) {
|
238
|
-
d1 += (10 - i) * parseInt(value.charAt(i), 10);
|
239
|
-
}
|
240
|
-
d1 = 11 - d1 % 11;
|
241
|
-
if (d1 === 10 || d1 === 11) {
|
242
|
-
d1 = 0;
|
243
|
-
}
|
244
|
-
if (d1 + '' !== value.charAt(9)) {
|
245
|
-
return false;
|
246
|
-
}
|
247
|
-
|
248
|
-
var d2 = 0;
|
249
|
-
for (i = 0; i < 10; i++) {
|
250
|
-
d2 += (11 - i) * parseInt(value.charAt(i), 10);
|
251
|
-
}
|
252
|
-
d2 = 11 - d2 % 11;
|
253
|
-
if (d2 === 10 || d2 === 11) {
|
254
|
-
d2 = 0;
|
255
|
-
}
|
256
|
-
|
257
|
-
return (d2 + '' === value.charAt(10));
|
258
|
-
},
|
259
|
-
|
260
|
-
/**
|
261
|
-
* Validate Swiss Social Security Number (AHV-Nr/No AVS)
|
262
|
-
* Examples:
|
263
|
-
* - Valid: 756.1234.5678.95, 7561234567895
|
264
|
-
*
|
265
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number#Switzerland
|
266
|
-
* @see http://www.bsv.admin.ch/themen/ahv/00011/02185/index.html?lang=de
|
267
|
-
* @param {String} value The ID
|
268
|
-
* @returns {Boolean}
|
269
|
-
*/
|
270
|
-
_ch: function(value) {
|
271
|
-
if (!/^756[\.]{0,1}[0-9]{4}[\.]{0,1}[0-9]{4}[\.]{0,1}[0-9]{2}$/.test(value)) {
|
272
|
-
return false;
|
273
|
-
}
|
274
|
-
value = value.replace(/\D/g, '').substr(3);
|
275
|
-
var length = value.length,
|
276
|
-
sum = 0,
|
277
|
-
weight = (length === 8) ? [3, 1] : [1, 3];
|
278
|
-
for (var i = 0; i < length - 1; i++) {
|
279
|
-
sum += parseInt(value.charAt(i), 10) * weight[i % 2];
|
280
|
-
}
|
281
|
-
sum = 10 - sum % 10;
|
282
|
-
return (sum + '' === value.charAt(length - 1));
|
283
|
-
},
|
284
|
-
|
285
|
-
/**
|
286
|
-
* Validate Chilean national identification number (RUN/RUT)
|
287
|
-
* Examples:
|
288
|
-
* - Valid: 76086428-5, 22060449-7, 12531909-2
|
289
|
-
*
|
290
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number#Chile
|
291
|
-
* @see https://palena.sii.cl/cvc/dte/ee_empresas_emisoras.html for samples
|
292
|
-
* @param {String} value The ID
|
293
|
-
* @returns {Boolean}
|
294
|
-
*/
|
295
|
-
_cl: function(value) {
|
296
|
-
if (!/^\d{7,8}[-]{0,1}[0-9K]$/i.test(value)) {
|
297
|
-
return false;
|
298
|
-
}
|
299
|
-
value = value.replace(/\-/g, '');
|
300
|
-
while (value.length < 9) {
|
301
|
-
value = '0' + value;
|
302
|
-
}
|
303
|
-
var sum = 0,
|
304
|
-
weight = [3, 2, 7, 6, 5, 4, 3, 2];
|
305
|
-
for (var i = 0; i < 8; i++) {
|
306
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
307
|
-
}
|
308
|
-
sum = 11 - sum % 11;
|
309
|
-
if (sum === 11) {
|
310
|
-
sum = 0;
|
311
|
-
} else if (sum === 10) {
|
312
|
-
sum = 'K';
|
313
|
-
}
|
314
|
-
return sum + '' === value.charAt(8).toUpperCase();
|
315
|
-
},
|
316
|
-
|
317
|
-
/**
|
318
|
-
* Validate Czech national identification number (RC)
|
319
|
-
* Examples:
|
320
|
-
* - Valid: 7103192745, 991231123
|
321
|
-
* - Invalid: 1103492745, 590312123
|
322
|
-
*
|
323
|
-
* @param {String} value The ID
|
324
|
-
* @returns {Boolean}
|
325
|
-
*/
|
326
|
-
_cz: function(value) {
|
327
|
-
if (!/^\d{9,10}$/.test(value)) {
|
328
|
-
return false;
|
329
|
-
}
|
330
|
-
var year = 1900 + parseInt(value.substr(0, 2), 10),
|
331
|
-
month = parseInt(value.substr(2, 2), 10) % 50 % 20,
|
332
|
-
day = parseInt(value.substr(4, 2), 10);
|
333
|
-
if (value.length === 9) {
|
334
|
-
if (year >= 1980) {
|
335
|
-
year -= 100;
|
336
|
-
}
|
337
|
-
if (year > 1953) {
|
338
|
-
return false;
|
339
|
-
}
|
340
|
-
} else if (year < 1954) {
|
341
|
-
year += 100;
|
342
|
-
}
|
343
|
-
|
344
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
|
345
|
-
return false;
|
346
|
-
}
|
347
|
-
|
348
|
-
// Check that the birth date is not in the future
|
349
|
-
if (value.length === 10) {
|
350
|
-
var check = parseInt(value.substr(0, 9), 10) % 11;
|
351
|
-
if (year < 1985) {
|
352
|
-
check = check % 10;
|
353
|
-
}
|
354
|
-
return (check + '' === value.substr(9, 1));
|
355
|
-
}
|
356
|
-
|
357
|
-
return true;
|
358
|
-
},
|
359
|
-
|
360
|
-
/**
|
361
|
-
* Validate Danish Personal Identification number (CPR)
|
362
|
-
* Examples:
|
363
|
-
* - Valid: 2110625629, 211062-5629
|
364
|
-
* - Invalid: 511062-5629
|
365
|
-
*
|
366
|
-
* @see https://en.wikipedia.org/wiki/Personal_identification_number_(Denmark)
|
367
|
-
* @param {String} value The ID
|
368
|
-
* @returns {Boolean}
|
369
|
-
*/
|
370
|
-
_dk: function(value) {
|
371
|
-
if (!/^[0-9]{6}[-]{0,1}[0-9]{4}$/.test(value)) {
|
372
|
-
return false;
|
373
|
-
}
|
374
|
-
value = value.replace(/-/g, '');
|
375
|
-
var day = parseInt(value.substr(0, 2), 10),
|
376
|
-
month = parseInt(value.substr(2, 2), 10),
|
377
|
-
year = parseInt(value.substr(4, 2), 10);
|
378
|
-
|
379
|
-
switch (true) {
|
380
|
-
case ('5678'.indexOf(value.charAt(6)) !== -1 && year >= 58):
|
381
|
-
year += 1800;
|
382
|
-
break;
|
383
|
-
case ('0123'.indexOf(value.charAt(6)) !== -1):
|
384
|
-
case ('49'.indexOf(value.charAt(6)) !== -1 && year >= 37):
|
385
|
-
year += 1900;
|
386
|
-
break;
|
387
|
-
default:
|
388
|
-
year += 2000;
|
389
|
-
break;
|
390
|
-
}
|
391
|
-
|
392
|
-
return $.fn.bootstrapValidator.helpers.date(year, month, day);
|
393
|
-
},
|
394
|
-
|
395
|
-
/**
|
396
|
-
* Validate Estonian Personal Identification Code (isikukood)
|
397
|
-
* Examples:
|
398
|
-
* - Valid: 37605030299
|
399
|
-
*
|
400
|
-
* @see http://et.wikipedia.org/wiki/Isikukood
|
401
|
-
* @param {String} value The ID
|
402
|
-
* @returns {Boolean}
|
403
|
-
*/
|
404
|
-
_ee: function(value) {
|
405
|
-
// Use the same format as Lithuanian Personal Code
|
406
|
-
return this._lt(value);
|
407
|
-
},
|
408
|
-
|
409
|
-
/**
|
410
|
-
* Validate Spanish personal identity code (DNI)
|
411
|
-
* Support i) DNI (for Spanish citizens) and ii) NIE (for foreign people)
|
412
|
-
*
|
413
|
-
* Examples:
|
414
|
-
* - Valid: i) 54362315K, 54362315-K; ii) X2482300W, X-2482300W, X-2482300-W
|
415
|
-
* - Invalid: i) 54362315Z; ii) X-2482300A
|
416
|
-
*
|
417
|
-
* @see https://en.wikipedia.org/wiki/National_identification_number#Spain
|
418
|
-
* @param {String} value The ID
|
419
|
-
* @returns {Boolean}
|
420
|
-
*/
|
421
|
-
_es: function(value) {
|
422
|
-
if (!/^[0-9A-Z]{8}[-]{0,1}[0-9A-Z]$/.test(value) // DNI
|
423
|
-
&& !/^[XYZ][-]{0,1}[0-9]{7}[-]{0,1}[0-9A-Z]$/.test(value)) { // NIE
|
424
|
-
return false;
|
425
|
-
}
|
426
|
-
|
427
|
-
value = value.replace(/-/g, '');
|
428
|
-
var index = 'XYZ'.indexOf(value.charAt(0));
|
429
|
-
if (index !== -1) {
|
430
|
-
// It is NIE number
|
431
|
-
value = index + value.substr(1) + '';
|
432
|
-
}
|
433
|
-
|
434
|
-
var check = parseInt(value.substr(0, 8), 10);
|
435
|
-
check = 'TRWAGMYFPDXBNJZSQVHLCKE'[check % 23];
|
436
|
-
return (check === value.substr(8, 1));
|
437
|
-
},
|
438
|
-
|
439
|
-
/**
|
440
|
-
* Validate Finnish Personal Identity Code (HETU)
|
441
|
-
* Examples:
|
442
|
-
* - Valid: 311280-888Y, 131052-308T
|
443
|
-
* - Invalid: 131052-308U, 310252-308Y
|
444
|
-
*
|
445
|
-
* @param {String} value The ID
|
446
|
-
* @returns {Boolean}
|
447
|
-
*/
|
448
|
-
_fi: function(value) {
|
449
|
-
if (!/^[0-9]{6}[-+A][0-9]{3}[0-9ABCDEFHJKLMNPRSTUVWXY]$/.test(value)) {
|
450
|
-
return false;
|
451
|
-
}
|
452
|
-
var day = parseInt(value.substr(0, 2), 10),
|
453
|
-
month = parseInt(value.substr(2, 2), 10),
|
454
|
-
year = parseInt(value.substr(4, 2), 10),
|
455
|
-
centuries = {
|
456
|
-
'+': 1800,
|
457
|
-
'-': 1900,
|
458
|
-
'A': 2000
|
459
|
-
};
|
460
|
-
year = centuries[value.charAt(6)] + year;
|
461
|
-
|
462
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
|
463
|
-
return false;
|
464
|
-
}
|
465
|
-
|
466
|
-
var individual = parseInt(value.substr(7, 3), 10);
|
467
|
-
if (individual < 2) {
|
468
|
-
return false;
|
469
|
-
}
|
470
|
-
var n = value.substr(0, 6) + value.substr(7, 3) + '';
|
471
|
-
n = parseInt(n, 10);
|
472
|
-
return '0123456789ABCDEFHJKLMNPRSTUVWXY'.charAt(n % 31) === value.charAt(10);
|
473
|
-
},
|
474
|
-
|
475
|
-
/**
|
476
|
-
* Validate Croatian personal identification number (OIB)
|
477
|
-
* Examples:
|
478
|
-
* - Valid: 33392005961
|
479
|
-
* - Invalid: 33392005962
|
480
|
-
*
|
481
|
-
* @param {String} value The ID
|
482
|
-
* @returns {Boolean}
|
483
|
-
*/
|
484
|
-
_hr: function(value) {
|
485
|
-
if (!/^[0-9]{11}$/.test(value)) {
|
486
|
-
return false;
|
487
|
-
}
|
488
|
-
return $.fn.bootstrapValidator.helpers.mod11And10(value);
|
489
|
-
},
|
490
|
-
|
491
|
-
/**
|
492
|
-
* Validate Irish Personal Public Service Number (PPS)
|
493
|
-
* Examples:
|
494
|
-
* - Valid: 6433435F, 6433435FT, 6433435FW, 6433435OA, 6433435IH, 1234567TW, 1234567FA
|
495
|
-
* - Invalid: 6433435E, 6433435VH
|
496
|
-
*
|
497
|
-
* @see https://en.wikipedia.org/wiki/Personal_Public_Service_Number
|
498
|
-
* @param {String} value The ID
|
499
|
-
* @returns {Boolean}
|
500
|
-
*/
|
501
|
-
_ie: function(value) {
|
502
|
-
if (!/^\d{7}[A-W][AHWTX]?$/.test(value)) {
|
503
|
-
return false;
|
504
|
-
}
|
505
|
-
|
506
|
-
var getCheckDigit = function(value) {
|
507
|
-
while (value.length < 7) {
|
508
|
-
value = '0' + value;
|
509
|
-
}
|
510
|
-
var alphabet = 'WABCDEFGHIJKLMNOPQRSTUV',
|
511
|
-
sum = 0;
|
512
|
-
for (var i = 0; i < 7; i++) {
|
513
|
-
sum += parseInt(value.charAt(i), 10) * (8 - i);
|
514
|
-
}
|
515
|
-
sum += 9 * alphabet.indexOf(value.substr(7));
|
516
|
-
return alphabet[sum % 23];
|
517
|
-
};
|
518
|
-
|
519
|
-
// 2013 format
|
520
|
-
if (value.length === 9 && ('A' === value.charAt(8) || 'H' === value.charAt(8))) {
|
521
|
-
return value.charAt(7) === getCheckDigit(value.substr(0, 7) + value.substr(8) + '');
|
522
|
-
}
|
523
|
-
// The old format
|
524
|
-
else {
|
525
|
-
return value.charAt(7) === getCheckDigit(value.substr(0, 7));
|
526
|
-
}
|
527
|
-
},
|
528
|
-
|
529
|
-
/**
|
530
|
-
* Validate Iceland national identification number (Kennitala)
|
531
|
-
* Examples:
|
532
|
-
* - Valid: 120174-3399, 1201743399, 0902862349
|
533
|
-
*
|
534
|
-
* @see http://en.wikipedia.org/wiki/Kennitala
|
535
|
-
* @param {String} value The ID
|
536
|
-
* @returns {Boolean}
|
537
|
-
*/
|
538
|
-
_is: function(value) {
|
539
|
-
if (!/^[0-9]{6}[-]{0,1}[0-9]{4}$/.test(value)) {
|
540
|
-
return false;
|
541
|
-
}
|
542
|
-
value = value.replace(/-/g, '');
|
543
|
-
var day = parseInt(value.substr(0, 2), 10),
|
544
|
-
month = parseInt(value.substr(2, 2), 10),
|
545
|
-
year = parseInt(value.substr(4, 2), 10),
|
546
|
-
century = parseInt(value.charAt(9), 10);
|
547
|
-
|
548
|
-
year = (century === 9) ? (1900 + year) : ((20 + century) * 100 + year);
|
549
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day, true)) {
|
550
|
-
return false;
|
551
|
-
}
|
552
|
-
// Validate the check digit
|
553
|
-
var sum = 0,
|
554
|
-
weight = [3, 2, 7, 6, 5, 4, 3, 2];
|
555
|
-
for (var i = 0; i < 8; i++) {
|
556
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
557
|
-
}
|
558
|
-
sum = 11 - sum % 11;
|
559
|
-
return (sum + '' === value.charAt(8));
|
560
|
-
},
|
561
|
-
|
562
|
-
/**
|
563
|
-
* Validate Lithuanian Personal Code (Asmens kodas)
|
564
|
-
* Examples:
|
565
|
-
* - Valid: 38703181745
|
566
|
-
* - Invalid: 38703181746, 78703181745, 38703421745
|
567
|
-
*
|
568
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number#Lithuania
|
569
|
-
* @see http://www.adomas.org/midi2007/pcode.html
|
570
|
-
* @param {String} value The ID
|
571
|
-
* @returns {Boolean}
|
572
|
-
*/
|
573
|
-
_lt: function(value) {
|
574
|
-
if (!/^[0-9]{11}$/.test(value)) {
|
575
|
-
return false;
|
576
|
-
}
|
577
|
-
var gender = parseInt(value.charAt(0), 10),
|
578
|
-
year = parseInt(value.substr(1, 2), 10),
|
579
|
-
month = parseInt(value.substr(3, 2), 10),
|
580
|
-
day = parseInt(value.substr(5, 2), 10),
|
581
|
-
century = (gender % 2 === 0) ? (17 + gender / 2) : (17 + (gender + 1) / 2);
|
582
|
-
year = century * 100 + year;
|
583
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day, true)) {
|
584
|
-
return false;
|
585
|
-
}
|
586
|
-
|
587
|
-
// Validate the check digit
|
588
|
-
var sum = 0,
|
589
|
-
weight = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1];
|
590
|
-
for (var i = 0; i < 10; i++) {
|
591
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
592
|
-
}
|
593
|
-
sum = sum % 11;
|
594
|
-
if (sum !== 10) {
|
595
|
-
return sum + '' === value.charAt(10);
|
596
|
-
}
|
597
|
-
|
598
|
-
// Re-calculate the check digit
|
599
|
-
sum = 0;
|
600
|
-
weight = [3, 4, 5, 6, 7, 8, 9, 1, 2, 3];
|
601
|
-
for (i = 0; i < 10; i++) {
|
602
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
603
|
-
}
|
604
|
-
sum = sum % 11;
|
605
|
-
if (sum === 10) {
|
606
|
-
sum = 0;
|
607
|
-
}
|
608
|
-
return (sum + '' === value.charAt(10));
|
609
|
-
},
|
610
|
-
|
611
|
-
/**
|
612
|
-
* Validate Latvian Personal Code (Personas kods)
|
613
|
-
* Examples:
|
614
|
-
* - Valid: 161175-19997, 16117519997
|
615
|
-
* - Invalid: 161375-19997
|
616
|
-
*
|
617
|
-
* @see http://laacz.lv/2006/11/25/pk-parbaudes-algoritms/
|
618
|
-
* @param {String} value The ID
|
619
|
-
* @returns {Boolean}
|
620
|
-
*/
|
621
|
-
_lv: function(value) {
|
622
|
-
if (!/^[0-9]{6}[-]{0,1}[0-9]{5}$/.test(value)) {
|
623
|
-
return false;
|
624
|
-
}
|
625
|
-
value = value.replace(/\D/g, '');
|
626
|
-
// Check birth date
|
627
|
-
var day = parseInt(value.substr(0, 2), 10),
|
628
|
-
month = parseInt(value.substr(2, 2), 10),
|
629
|
-
year = parseInt(value.substr(4, 2), 10);
|
630
|
-
year = year + 1800 + parseInt(value.charAt(6), 10) * 100;
|
631
|
-
|
632
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day, true)) {
|
633
|
-
return false;
|
634
|
-
}
|
635
|
-
|
636
|
-
// Check personal code
|
637
|
-
var sum = 0,
|
638
|
-
weight = [10, 5, 8, 4, 2, 1, 6, 3, 7, 9];
|
639
|
-
for (var i = 0; i < 10; i++) {
|
640
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
641
|
-
}
|
642
|
-
sum = (sum + 1) % 11 % 10;
|
643
|
-
return (sum + '' === value.charAt(10));
|
644
|
-
},
|
645
|
-
|
646
|
-
/**
|
647
|
-
* Validate Dutch national identification number (BSN)
|
648
|
-
* Examples:
|
649
|
-
* - Valid: 111222333, 941331490, 9413.31.490
|
650
|
-
* - Invalid: 111252333
|
651
|
-
*
|
652
|
-
* @see https://nl.wikipedia.org/wiki/Burgerservicenummer
|
653
|
-
* @param {String} value The ID
|
654
|
-
* @returns {Boolean}
|
655
|
-
*/
|
656
|
-
_nl: function(value) {
|
657
|
-
while (value.length < 9) {
|
658
|
-
value = '0' + value;
|
659
|
-
}
|
660
|
-
if (!/^[0-9]{4}[.]{0,1}[0-9]{2}[.]{0,1}[0-9]{3}$/.test(value)) {
|
661
|
-
return false;
|
662
|
-
}
|
663
|
-
value = value.replace(/\./g, '');
|
664
|
-
if (parseInt(value, 10) === 0) {
|
665
|
-
return false;
|
666
|
-
}
|
667
|
-
var sum = 0,
|
668
|
-
length = value.length;
|
669
|
-
for (var i = 0; i < length - 1; i++) {
|
670
|
-
sum += (9 - i) * parseInt(value.charAt(i), 10);
|
671
|
-
}
|
672
|
-
sum = sum % 11;
|
673
|
-
if (sum === 10) {
|
674
|
-
sum = 0;
|
675
|
-
}
|
676
|
-
return (sum + '' === value.charAt(length - 1));
|
677
|
-
},
|
678
|
-
|
679
|
-
/**
|
680
|
-
* Validate Romanian numerical personal code (CNP)
|
681
|
-
* Examples:
|
682
|
-
* - Valid: 1630615123457, 1800101221144
|
683
|
-
* - Invalid: 8800101221144, 1632215123457, 1630615123458
|
684
|
-
*
|
685
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number#Romania
|
686
|
-
* @param {String} value The ID
|
687
|
-
* @returns {Boolean}
|
688
|
-
*/
|
689
|
-
_ro: function(value) {
|
690
|
-
if (!/^[0-9]{13}$/.test(value)) {
|
691
|
-
return false;
|
692
|
-
}
|
693
|
-
var gender = parseInt(value.charAt(0), 10);
|
694
|
-
if (gender === 0 || gender === 7 || gender === 8) {
|
695
|
-
return false;
|
696
|
-
}
|
697
|
-
|
698
|
-
// Determine the date of birth
|
699
|
-
var year = parseInt(value.substr(1, 2), 10),
|
700
|
-
month = parseInt(value.substr(3, 2), 10),
|
701
|
-
day = parseInt(value.substr(5, 2), 10),
|
702
|
-
// The year of date is determined base on the gender
|
703
|
-
centuries = {
|
704
|
-
'1': 1900, // Male born between 1900 and 1999
|
705
|
-
'2': 1900, // Female born between 1900 and 1999
|
706
|
-
'3': 1800, // Male born between 1800 and 1899
|
707
|
-
'4': 1800, // Female born between 1800 and 1899
|
708
|
-
'5': 2000, // Male born after 2000
|
709
|
-
'6': 2000 // Female born after 2000
|
710
|
-
};
|
711
|
-
if (day > 31 && month > 12) {
|
712
|
-
return false;
|
713
|
-
}
|
714
|
-
if (gender !== 9) {
|
715
|
-
year = centuries[gender + ''] + year;
|
716
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
|
717
|
-
return false;
|
718
|
-
}
|
719
|
-
}
|
720
|
-
|
721
|
-
// Validate the check digit
|
722
|
-
var sum = 0,
|
723
|
-
weight = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9],
|
724
|
-
length = value.length;
|
725
|
-
for (var i = 0; i < length - 1; i++) {
|
726
|
-
sum += parseInt(value.charAt(i), 10) * weight[i];
|
727
|
-
}
|
728
|
-
sum = sum % 11;
|
729
|
-
if (sum === 10) {
|
730
|
-
sum = 1;
|
731
|
-
}
|
732
|
-
return (sum + '' === value.charAt(length - 1));
|
733
|
-
},
|
734
|
-
|
735
|
-
/**
|
736
|
-
* Validate Swedish personal identity number (personnummer)
|
737
|
-
* Examples:
|
738
|
-
* - Valid: 8112289874, 811228-9874, 811228+9874
|
739
|
-
* - Invalid: 811228-9873
|
740
|
-
*
|
741
|
-
* @see http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
|
742
|
-
* @param {String} value The ID
|
743
|
-
* @returns {Boolean}
|
744
|
-
*/
|
745
|
-
_se: function(value) {
|
746
|
-
if (!/^[0-9]{10}$/.test(value) && !/^[0-9]{6}[-|+][0-9]{4}$/.test(value)) {
|
747
|
-
return false;
|
748
|
-
}
|
749
|
-
value = value.replace(/[^0-9]/g, '');
|
750
|
-
|
751
|
-
var year = parseInt(value.substr(0, 2), 10) + 1900,
|
752
|
-
month = parseInt(value.substr(2, 2), 10),
|
753
|
-
day = parseInt(value.substr(4, 2), 10);
|
754
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
|
755
|
-
return false;
|
756
|
-
}
|
757
|
-
|
758
|
-
// Validate the last check digit
|
759
|
-
return $.fn.bootstrapValidator.helpers.luhn(value);
|
760
|
-
},
|
761
|
-
|
762
|
-
/**
|
763
|
-
* Validate Slovak national identifier number (RC)
|
764
|
-
* Examples:
|
765
|
-
* - Valid: 7103192745, 991231123
|
766
|
-
* - Invalid: 7103192746, 1103492745
|
767
|
-
*
|
768
|
-
* @param {String} value The ID
|
769
|
-
* @returns {Boolean}
|
770
|
-
*/
|
771
|
-
_sk: function(value) {
|
772
|
-
// Slovakia uses the same format as Czech Republic
|
773
|
-
return this._cz(value);
|
774
|
-
},
|
775
|
-
|
776
|
-
/**
|
777
|
-
* Validate San Marino citizen number
|
778
|
-
*
|
779
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number#San_Marino
|
780
|
-
* @param {String} value The ID
|
781
|
-
* @returns {Boolean}
|
782
|
-
*/
|
783
|
-
_sm: function(value) {
|
784
|
-
return /^\d{5}$/.test(value);
|
785
|
-
},
|
786
|
-
|
787
|
-
/**
|
788
|
-
* Validate South African ID
|
789
|
-
* Example:
|
790
|
-
* - Valid: 8001015009087
|
791
|
-
* - Invalid: 8001015009287, 8001015009086
|
792
|
-
*
|
793
|
-
* @see http://en.wikipedia.org/wiki/National_identification_number#South_Africa
|
794
|
-
* @param {String} value The ID
|
795
|
-
* @returns {Boolean}
|
796
|
-
*/
|
797
|
-
_za: function(value) {
|
798
|
-
if (!/^[0-9]{10}[0|1][8|9][0-9]$/.test(value)) {
|
799
|
-
return false;
|
800
|
-
}
|
801
|
-
var year = parseInt(value.substr(0, 2), 10),
|
802
|
-
currentYear = new Date().getFullYear() % 100,
|
803
|
-
month = parseInt(value.substr(2, 2), 10),
|
804
|
-
day = parseInt(value.substr(4, 2), 10);
|
805
|
-
year = (year >= currentYear) ? (year + 1900) : (year + 2000);
|
806
|
-
|
807
|
-
if (!$.fn.bootstrapValidator.helpers.date(year, month, day)) {
|
808
|
-
return false;
|
809
|
-
}
|
810
|
-
|
811
|
-
// Validate the last check digit
|
812
|
-
return $.fn.bootstrapValidator.helpers.luhn(value);
|
813
|
-
}
|
814
|
-
};
|
815
|
-
}(window.jQuery));
|