formvalidation-rails 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -6
  3. data/lib/formvalidation-rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/formvalidation.js +521 -501
  5. data/vendor/assets/javascripts/formvalidation.min.js +6 -6
  6. data/vendor/assets/javascripts/formvalidation/framework/bootstrap.js +4 -3
  7. data/vendor/assets/javascripts/formvalidation/framework/bootstrap.min.js +3 -3
  8. data/vendor/assets/javascripts/formvalidation/framework/foundation.js +3 -3
  9. data/vendor/assets/javascripts/formvalidation/framework/foundation.min.js +3 -3
  10. data/vendor/assets/javascripts/formvalidation/framework/pure.js +3 -3
  11. data/vendor/assets/javascripts/formvalidation/framework/pure.min.js +3 -3
  12. data/vendor/assets/javascripts/formvalidation/framework/semantic.js +3 -3
  13. data/vendor/assets/javascripts/formvalidation/framework/semantic.min.js +3 -3
  14. data/vendor/assets/javascripts/formvalidation/framework/uikit.js +3 -3
  15. data/vendor/assets/javascripts/formvalidation/framework/uikit.min.js +3 -3
  16. data/vendor/assets/javascripts/formvalidation/language/ar_MA.js +6 -1
  17. data/vendor/assets/javascripts/formvalidation/language/bg_BG.js +6 -1
  18. data/vendor/assets/javascripts/formvalidation/language/ca_ES.js +6 -1
  19. data/vendor/assets/javascripts/formvalidation/language/cs_CZ.js +6 -1
  20. data/vendor/assets/javascripts/formvalidation/language/da_DK.js +6 -1
  21. data/vendor/assets/javascripts/formvalidation/language/de_DE.js +6 -1
  22. data/vendor/assets/javascripts/formvalidation/language/{gr_EL.js → el_GR.js} +7 -2
  23. data/vendor/assets/javascripts/formvalidation/language/en_US.js +6 -1
  24. data/vendor/assets/javascripts/formvalidation/language/es_CL.js +6 -1
  25. data/vendor/assets/javascripts/formvalidation/language/es_ES.js +6 -1
  26. data/vendor/assets/javascripts/formvalidation/language/eu_ES.js +6 -1
  27. data/vendor/assets/javascripts/formvalidation/language/fa_IR.js +6 -1
  28. data/vendor/assets/javascripts/formvalidation/language/fi_FI.js +6 -1
  29. data/vendor/assets/javascripts/formvalidation/language/{be_FR.js → fr_BE.js} +7 -2
  30. data/vendor/assets/javascripts/formvalidation/language/fr_FR.js +6 -1
  31. data/vendor/assets/javascripts/formvalidation/language/he_IL.js +6 -1
  32. data/vendor/assets/javascripts/formvalidation/language/hi_IN.js +6 -1
  33. data/vendor/assets/javascripts/formvalidation/language/hu_HU.js +6 -1
  34. data/vendor/assets/javascripts/formvalidation/language/id_ID.js +6 -1
  35. data/vendor/assets/javascripts/formvalidation/language/it_IT.js +6 -1
  36. data/vendor/assets/javascripts/formvalidation/language/ja_JP.js +6 -1
  37. data/vendor/assets/javascripts/formvalidation/language/{be_NL.js → nl_BE.js} +7 -2
  38. data/vendor/assets/javascripts/formvalidation/language/nl_NL.js +6 -1
  39. data/vendor/assets/javascripts/formvalidation/language/no_NO.js +6 -1
  40. data/vendor/assets/javascripts/formvalidation/language/pl_PL.js +6 -1
  41. data/vendor/assets/javascripts/formvalidation/language/pt_BR.js +6 -1
  42. data/vendor/assets/javascripts/formvalidation/language/pt_PT.js +6 -1
  43. data/vendor/assets/javascripts/formvalidation/language/ro_RO.js +6 -1
  44. data/vendor/assets/javascripts/formvalidation/language/ru_RU.js +6 -1
  45. data/vendor/assets/javascripts/formvalidation/language/sk_SK.js +6 -1
  46. data/vendor/assets/javascripts/formvalidation/language/sq_AL.js +6 -1
  47. data/vendor/assets/javascripts/formvalidation/language/sr_RS.js +6 -1
  48. data/vendor/assets/javascripts/formvalidation/language/sv_SE.js +6 -1
  49. data/vendor/assets/javascripts/formvalidation/language/th_TH.js +6 -1
  50. data/vendor/assets/javascripts/formvalidation/language/tr_TR.js +6 -1
  51. data/vendor/assets/javascripts/formvalidation/language/ua_UA.js +6 -1
  52. data/vendor/assets/javascripts/formvalidation/language/vi_VN.js +6 -1
  53. data/vendor/assets/javascripts/formvalidation/language/zh_CN.js +6 -1
  54. data/vendor/assets/javascripts/formvalidation/language/zh_TW.js +6 -1
  55. data/vendor/assets/stylesheets/formvalidation.css +6 -1
  56. data/vendor/assets/stylesheets/formvalidation.min.css +1 -1
  57. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88e0a6b3ad367af0794b86fedf6795621ebb8256
4
- data.tar.gz: a84f6403ddec221611339e2497ec1ff3ab0956a6
3
+ metadata.gz: 508aa888c54567ee1fd53cc373fbc8f262d4e010
4
+ data.tar.gz: 7069f66c31732f68cf2654189eedc3c0502b18be
5
5
  SHA512:
6
- metadata.gz: 6dcc345f95be570d2ae9be05bb2a0b960e7cf622088bc2014c0b489084c846e78d6c13f518b6913e57c5398c76e79b999825a4deaf2701e772c8ae55297e2c96
7
- data.tar.gz: f41b339002088b6045eabe200e809382bbeeeffc934f1748ecfb7cd6a3fdbe8a238c0ed3c39c58e6355eea3cf468c023e0f3b120c93e97c46648e4ccc33a2163
6
+ metadata.gz: 64da37953d0636a8648bbb1ed5a2fee7747112c0e88347a908c15393165fc65c13b3b9480c96141301f89d238b37a148d4f1f12e0bf387d4cc49be307507b4a9
7
+ data.tar.gz: 6e476090b60cdb2320d86e1cac3f998f1e74b837702c10bdd07c5e3b110249113565c948c4c91e577831a9d0fb63b959ed4740369da29512cea00b53319bc2c3
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- formvalidation-rails (0.6.3)
1
+ formvalidation-rails (0.7.0)
2
2
  =================================
3
3
 
4
4
  Provides client side validations for forms with the http://formvalidation.io/ library.
@@ -6,6 +6,11 @@ Provides client side validations for forms with the http://formvalidation.io/ li
6
6
  The original formvalidation repo can be found here: https://github.com/formvalidation/formvalidation.
7
7
  This is only a gem containing a release version for easier use.
8
8
 
9
+ ### Important
10
+
11
+ For commercial use a commercial license for formvalidation.io needs to be purchased at http://formvalidation.io/.
12
+ This gem only provides a package for easier use with RubyOnRails but does not affect the original license of
13
+ formvalidation.io.
9
14
 
10
15
  ### How to Use
11
16
 
@@ -37,11 +42,6 @@ And if needed the extension (for html frameworks) and language packs you need:
37
42
  `*= require formvalidation.min`
38
43
 
39
44
 
40
- ### License
41
-
42
- **Important** for commercial use a commercial license for formvalidation.io needs to be purchased at http://formvalidation.io/
43
-
44
-
45
45
  ### Credits
46
46
 
47
47
  This gem was build after the example of https://rubygems.org/gems/bootstrap-validator-rails, a earlier version of formvalidation.io under a different name.
@@ -1,6 +1,6 @@
1
1
  module FormvalidationRails
2
2
  module Rails
3
- VERSION = '0.6.3'
4
- SOURCE_VERSION = '0.6.3'
3
+ VERSION = '0.7.0'
4
+ SOURCE_VERSION = '0.7.0'
5
5
  end
6
6
  end
@@ -2,8 +2,8 @@
2
2
  * FormValidation (http://formvalidation.io)
3
3
  * The best jQuery plugin to validate form fields. Support Bootstrap, Foundation, Pure, SemanticUI, UIKit and custom frameworks
4
4
  *
5
- * @version v0.6.2-dev, built on 2015-03-13 8:15:45 AM
6
- * @author https://twitter.com/nghuuphuoc
5
+ * @version v0.7.0, built on 2015-08-01 4:57:16 PM
6
+ * @author https://twitter.com/formvalidation
7
7
  * @copyright (c) 2013 - 2015 Nguyen Huu Phuoc
8
8
  * @license http://formvalidation.io/license/
9
9
  */
@@ -27,7 +27,7 @@ if (typeof jQuery === 'undefined') {
27
27
  }(jQuery));
28
28
 
29
29
  (function($) {
30
- // TODO: Remove backward compatibility in v0.7.0
30
+ // TODO: Remove backward compatibility
31
31
  /**
32
32
  * Constructor
33
33
  *
@@ -53,19 +53,22 @@ if (typeof jQuery === 'undefined') {
53
53
  this.STATUS_VALID = 'VALID';
54
54
  this.STATUS_IGNORED = 'IGNORED';
55
55
 
56
+ // Default message
57
+ this.DEFAULT_MESSAGE = $.fn.formValidation.DEFAULT_MESSAGE;
58
+
56
59
  // Determine the event that is fired when user change the field value
57
60
  // Most modern browsers supports input event except IE 7, 8.
58
61
  // IE 9 supports input event but the event is still not fired if I press the backspace key.
59
62
  // Get IE version
60
63
  // https://gist.github.com/padolsey/527683/#comment-7595
61
- var ieVersion = (function() {
64
+ this._ieVersion = (function() {
62
65
  var v = 3, div = document.createElement('div'), a = div.all || [];
63
66
  while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]) {}
64
- return v > 4 ? v : !v;
67
+ return v > 4 ? v : document.documentMode;
65
68
  }());
66
69
 
67
70
  var el = document.createElement('div');
68
- this._changeEvent = (ieVersion === 9 || !('oninput' in el)) ? 'keyup' : 'input';
71
+ this._changeEvent = (this._ieVersion === 9 || !('oninput' in el)) ? 'keyup' : 'input';
69
72
 
70
73
  // The flag to indicate that the form is ready to submit when a remote/callback validator returns
71
74
  this._submitIfValid = null;
@@ -120,6 +123,7 @@ if (typeof jQuery === 'undefined') {
120
123
  },
121
124
  events: {
122
125
  formInit: this.$form.attr('data-' + ns + '-events-form-init'),
126
+ formPreValidate: this.$form.attr('data-' + ns + '-events-form-prevalidate'),
123
127
  formError: this.$form.attr('data-' + ns + '-events-form-error'),
124
128
  formSuccess: this.$form.attr('data-' + ns + '-events-form-success'),
125
129
  fieldAdded: this.$form.attr('data-' + ns + '-events-field-added'),
@@ -143,6 +147,7 @@ if (typeof jQuery === 'undefined') {
143
147
  live: this.$form.attr('data-' + ns + '-live'),
144
148
  locale: this.$form.attr('data-' + ns + '-locale'),
145
149
  message: this.$form.attr('data-' + ns + '-message'),
150
+ onPreValidate: this.$form.attr('data-' + ns + '-onprevalidate'),
146
151
  onError: this.$form.attr('data-' + ns + '-onerror'),
147
152
  onSuccess: this.$form.attr('data-' + ns + '-onsuccess'),
148
153
  row: {
@@ -176,7 +181,7 @@ if (typeof jQuery === 'undefined') {
176
181
  // Find all fields which have either "name" or "data-{namespace}-field" attribute
177
182
  this.$form
178
183
  .find('[name], [data-' + ns + '-field]')
179
- .each(function () {
184
+ .each(function() {
180
185
  var $field = $(this),
181
186
  field = $field.attr('name') || $field.attr('data-' + ns + '-field'),
182
187
  opts = that._parseOptions($field);
@@ -239,8 +244,8 @@ if (typeof jQuery === 'undefined') {
239
244
  // The button might contain HTML tag
240
245
  $button = $target.is('[type="submit"]') ? $target.eq(0) : $target.parent('[type="submit"]').eq(0);
241
246
 
242
- // Don't perform validation when clicking on the submit button/input
243
- // which aren't defined by the 'button.selector' option
247
+ // Don't perform validation when clicking on the submit button/input which
248
+ // aren't defined by the 'button.selector' option
244
249
  if (that.options.button.selector && !$button.is(that.options.button.selector) && !$button.is(that.$hiddenButton)) {
245
250
  that.$form.off('submit.' + that._namespace).submit();
246
251
  }
@@ -265,6 +270,11 @@ if (typeof jQuery === 'undefined') {
265
270
  });
266
271
 
267
272
  // Prepare the events
273
+ if (this.options.onPreValidate) {
274
+ this.$form.on(this.options.events.formPreValidate, function(e) {
275
+ FormValidation.Helper.call(that.options.onPreValidate, [e]);
276
+ });
277
+ }
268
278
  if (this.options.onSuccess) {
269
279
  this.$form.on(this.options.events.formSuccess, function(e) {
270
280
  FormValidation.Helper.call(that.options.onSuccess, [e]);
@@ -307,9 +317,12 @@ if (typeof jQuery === 'undefined') {
307
317
  return;
308
318
  }
309
319
 
310
- var validatorName;
311
- for (validatorName in this.options.fields[field].validators) {
312
- if (!FormValidation.Validator[validatorName]) {
320
+ var validators = this.options.fields[field].validators,
321
+ validatorName,
322
+ alias;
323
+ for (validatorName in validators) {
324
+ alias = validators[validatorName].alias || validatorName;
325
+ if (!FormValidation.Validator[alias]) {
313
326
  delete this.options.fields[field].validators[validatorName];
314
327
  }
315
328
  }
@@ -352,7 +365,7 @@ if (typeof jQuery === 'undefined') {
352
365
 
353
366
  // Create help block elements for showing the error messages
354
367
  $field.data(ns + '.messages', $message);
355
- for (validatorName in this.options.fields[field].validators) {
368
+ for (validatorName in validators) {
356
369
  $field.data(ns + '.result.' + validatorName, this.STATUS_NOT_VALIDATED);
357
370
 
358
371
  if (!updateAll || i === total - 1) {
@@ -367,8 +380,9 @@ if (typeof jQuery === 'undefined') {
367
380
  }
368
381
 
369
382
  // Init the validator
370
- if ('function' === typeof FormValidation.Validator[validatorName].init) {
371
- FormValidation.Validator[validatorName].init(this, $field, this.options.fields[field].validators[validatorName]);
383
+ alias = validators[validatorName].alias || validatorName;
384
+ if ('function' === typeof FormValidation.Validator[alias].init) {
385
+ FormValidation.Validator[alias].init(this, $field, this.options.fields[field].validators[validatorName], validatorName);
372
386
  }
373
387
  }
374
388
 
@@ -403,12 +417,12 @@ if (typeof jQuery === 'undefined') {
403
417
  // Show tooltip/popover message when field gets focus
404
418
  .off('focus.container.' + ns)
405
419
  .on('focus.container.' + ns, function() {
406
- that._showTooltip($field, container);
420
+ that._showTooltip($(this), container);
407
421
  })
408
422
  // and hide them when losing focus
409
423
  .off('blur.container.' + ns)
410
424
  .on('blur.container.' + ns, function() {
411
- that._hideTooltip($field, container);
425
+ that._hideTooltip($(this), container);
412
426
  });
413
427
  }
414
428
 
@@ -446,6 +460,12 @@ if (typeof jQuery === 'undefined') {
446
460
  FormValidation.Helper.call(onError, [e, data]);
447
461
  }
448
462
  })
463
+ .on(this.options.events.validatorIgnored, function(e, data) {
464
+ var onIgnored = that.getOptions(data.field, data.validator, 'onIgnored');
465
+ if (onIgnored) {
466
+ FormValidation.Helper.call(onIgnored, [e, data]);
467
+ }
468
+ })
449
469
  .on(this.options.events.validatorSuccess, function(e, data) {
450
470
  var onSuccess = that.getOptions(data.field, data.validator, 'onSuccess');
451
471
  if (onSuccess) {
@@ -534,9 +554,13 @@ if (typeof jQuery === 'undefined') {
534
554
  return trigger;
535
555
  }
536
556
 
557
+ // IE10/11 auto fires input event of elements using the placeholder attribute
558
+ // https://connect.microsoft.com/IE/feedback/details/856700/
537
559
  var type = $field.attr('type'),
538
560
  name = $field.attr('data-' + ns + '-field'),
539
- event = ('radio' === type || 'checkbox' === type || 'file' === type || 'SELECT' === $field.get(0).tagName) ? 'change' : this._changeEvent;
561
+ event = ('radio' === type || 'checkbox' === type || 'file' === type || 'SELECT' === $field.get(0).tagName)
562
+ ? 'change'
563
+ : (this._ieVersion >= 10 && $field.attr('placeholder') ? 'keyup' : this._changeEvent);
540
564
  trigger = ((this.options.fields[name] ? this.options.fields[name].trigger : null) || this.options.trigger || event).split(' ');
541
565
 
542
566
  // Since the trigger data is used many times, I need to cache it to use later
@@ -553,21 +577,26 @@ if (typeof jQuery === 'undefined') {
553
577
  * @returns {String}
554
578
  */
555
579
  _getMessage: function(field, validatorName) {
556
- if (!this.options.fields[field] || !FormValidation.Validator[validatorName]
557
- || !this.options.fields[field].validators || !this.options.fields[field].validators[validatorName])
558
- {
580
+ if (!this.options.fields[field] || !this.options.fields[field].validators) {
581
+ return '';
582
+ }
583
+ var validators = this.options.fields[field].validators,
584
+ alias = (validators[validatorName] && validators[validatorName].alias) ? validators[validatorName].alias : validatorName;
585
+ if (!FormValidation.Validator[alias]) {
559
586
  return '';
560
587
  }
561
588
 
562
589
  switch (true) {
563
- case !!this.options.fields[field].validators[validatorName].message:
564
- return this.options.fields[field].validators[validatorName].message;
590
+ case !!validators[validatorName].message:
591
+ return validators[validatorName].message;
565
592
  case !!this.options.fields[field].message:
566
593
  return this.options.fields[field].message;
567
- case (!!FormValidation.I18n[this.options.locale] && !!FormValidation.I18n[this.options.locale][validatorName] && !!FormValidation.I18n[this.options.locale][validatorName]['default']):
568
- return FormValidation.I18n[this.options.locale][validatorName]['default'];
569
- default:
594
+ case !!this.options.message:
570
595
  return this.options.message;
596
+ case (!!FormValidation.I18n[this.options.locale] && !!FormValidation.I18n[this.options.locale][alias] && !!FormValidation.I18n[this.options.locale][alias]['default']):
597
+ return FormValidation.I18n[this.options.locale][alias]['default'];
598
+ default:
599
+ return this.DEFAULT_MESSAGE;
571
600
  }
572
601
  },
573
602
 
@@ -649,9 +678,11 @@ if (typeof jQuery === 'undefined') {
649
678
  * @returns {Object}
650
679
  */
651
680
  _parseOptions: function($field) {
652
- var ns = this._namespace,
653
- field = $field.attr('name') || $field.attr('data-' + ns + '-field'),
654
- validators = {},
681
+ var ns = this._namespace,
682
+ field = $field.attr('name') || $field.attr('data-' + ns + '-field'),
683
+ validators = {},
684
+ aliasAttr = new RegExp('^data-' + ns + '-([a-z]+)-alias$'),
685
+ validatorSet = $.extend({}, FormValidation.Validator),
655
686
  validator,
656
687
  v, // Validator name
657
688
  attrName,
@@ -662,8 +693,19 @@ if (typeof jQuery === 'undefined') {
662
693
  html5AttrName,
663
694
  html5AttrMap;
664
695
 
665
- for (v in FormValidation.Validator) {
666
- validator = FormValidation.Validator[v];
696
+ // Determine whether the alias validator is used by checking the data-fv-validator-alias attribute
697
+ $.each($field.get(0).attributes, function(i, attribute) {
698
+ if (attribute.value && aliasAttr.test(attribute.name)) {
699
+ v = attribute.name.split('-')[2];
700
+ if (validatorSet[attribute.value]) {
701
+ validatorSet[v] = validatorSet[attribute.value];
702
+ validatorSet[v].alias = attribute.value;
703
+ }
704
+ }
705
+ });
706
+
707
+ for (v in validatorSet) {
708
+ validator = validatorSet[v];
667
709
  attrName = 'data-' + ns + '-' + v.toLowerCase(),
668
710
  enabled = $field.attr(attrName) + '';
669
711
  html5AttrMap = ('function' === typeof validator.enableByHtml5) ? validator.enableByHtml5($field) : null;
@@ -679,11 +721,14 @@ if (typeof jQuery === 'undefined') {
679
721
  transformer: 'transformer'
680
722
  }, validator.html5Attributes);
681
723
  validators[v] = $.extend({}, html5AttrMap === true ? {} : html5AttrMap, validators[v]);
724
+ if (validator.alias) {
725
+ validators[v].alias = validator.alias;
726
+ }
682
727
 
683
728
  for (html5AttrName in validator.html5Attributes) {
684
- optionName = validator.html5Attributes[html5AttrName];
685
- optionAttrName = 'data-' + ns + '-' + v.toLowerCase() + '-' + html5AttrName,
686
- optionValue = $field.attr(optionAttrName);
729
+ optionName = validator.html5Attributes[html5AttrName];
730
+ optionAttrName = 'data-' + ns + '-' + v.toLowerCase() + '-' + html5AttrName;
731
+ optionValue = $field.attr(optionAttrName);
687
732
  if (optionValue) {
688
733
  if ('true' === optionValue || optionAttrName === optionValue.toLowerCase()) {
689
734
  optionValue = true;
@@ -699,6 +744,7 @@ if (typeof jQuery === 'undefined') {
699
744
  var opts = {
700
745
  autoFocus: $field.attr('data-' + ns + '-autofocus'),
701
746
  err: $field.attr('data-' + ns + '-err-container') || $field.attr('data-' + ns + '-container'), // Support backward
747
+ enabled: $field.attr('data-' + ns + '-enabled'),
702
748
  excluded: $field.attr('data-' + ns + '-excluded'),
703
749
  icon: $field.attr('data-' + ns + '-icon') || $field.attr('data-' + ns + '-feedbackicons') || (this.options.fields && this.options.fields[field] ? this.options.fields[field].feedbackIcons : null), // Support backward
704
750
  message: $field.attr('data-' + ns + '-message'),
@@ -717,7 +763,7 @@ if (typeof jQuery === 'undefined') {
717
763
  emptyValidators = $.isEmptyObject(validators); // Check if the field validators are set using HTML attributes
718
764
 
719
765
  if (!emptyValidators || (!emptyOptions && this.options.fields && this.options.fields[field])) {
720
- opts.validators = validators;
766
+ //opts.validators = validators;
721
767
  return opts;
722
768
  } else {
723
769
  return null;
@@ -1161,6 +1207,12 @@ if (typeof jQuery === 'undefined') {
1161
1207
  $errors = $f.data(ns + '.messages')
1162
1208
  .find('.' + this.options.err.clazz.split(' ').join('.') + '[data-' + ns + '-validator][data-' + ns + '-for="' + field + '"]');
1163
1209
 
1210
+ if (this.options.fields && this.options.fields[field]
1211
+ && (this.options.fields[field].enabled === 'false' || this.options.fields[field].enabled === false))
1212
+ {
1213
+ continue;
1214
+ }
1215
+
1164
1216
  if ($errors.filter('[data-' + ns + '-result="' + this.STATUS_INVALID + '"]').length > 0) {
1165
1217
  return false;
1166
1218
  }
@@ -1199,7 +1251,9 @@ if (typeof jQuery === 'undefined') {
1199
1251
  default:
1200
1252
  break;
1201
1253
  }
1202
- if (fields.length === 0 || !this.options.fields[field] || this.options.fields[field].enabled === false) {
1254
+ if (fields.length === 0 || !this.options.fields[field]
1255
+ || this.options.fields[field].enabled === 'false' || this.options.fields[field].enabled === false)
1256
+ {
1203
1257
  return true;
1204
1258
  }
1205
1259
 
@@ -1411,16 +1465,18 @@ if (typeof jQuery === 'undefined') {
1411
1465
  }
1412
1466
  break;
1413
1467
 
1414
- case this.STATUS_VALID:
1415
1468
  case this.STATUS_IGNORED: // Treat ignored fields like they are valid with some specialties
1469
+ case this.STATUS_VALID:
1416
1470
  isValidating = ($allErrors.filter('[data-' + ns + '-result="' + this.STATUS_VALIDATING +'"]').length > 0);
1417
1471
  isNotValidated = ($allErrors.filter('[data-' + ns + '-result="' + this.STATUS_NOT_VALIDATED +'"]').length > 0);
1418
1472
 
1473
+ var numIgnored = $allErrors.filter('[data-' + ns + '-result="' + this.STATUS_IGNORED +'"]').length;
1474
+
1419
1475
  // If the field is valid (passes all validators)
1420
1476
  isValidField = (isValidating || isNotValidated) // There are some validators that have not done
1421
- ? null
1422
- : ($allErrors.filter('[data-' + ns + '-result="' + this.STATUS_VALID +'"]').length
1423
- + $allErrors.filter('[data-' + ns + '-result="' + this.STATUS_IGNORED +'"]').length === $allErrors.length); // All validators are completed
1477
+ ? null
1478
+ // All validators are completed
1479
+ : ($allErrors.filter('[data-' + ns + '-result="' + this.STATUS_VALID +'"]').length + numIgnored === $allErrors.length);
1424
1480
 
1425
1481
  $field.removeClass(this.options.control.valid).removeClass(this.options.control.invalid);
1426
1482
 
@@ -1438,9 +1494,10 @@ if (typeof jQuery === 'undefined') {
1438
1494
 
1439
1495
  if ($icon) {
1440
1496
  $icon.removeClass(this.options.icon.invalid).removeClass(this.options.icon.validating).removeClass(this.options.icon.valid);
1441
- if (status === this.STATUS_VALID) {
1442
- $icon.addClass(isValidField === null
1443
- ? '' : (isValidField ? this.options.icon.valid : (isValidating ? this.options.icon.validating : this.options.icon.invalid)))
1497
+ if (status === this.STATUS_VALID || numIgnored !== $allErrors.length) {
1498
+ $icon.addClass(isValidating
1499
+ ? this.options.icon.validating
1500
+ : (isValidField === null ? '' : (isValidField ? this.options.icon.valid : this.options.icon.invalid)))
1444
1501
  .show();
1445
1502
  }
1446
1503
  }
@@ -1448,8 +1505,7 @@ if (typeof jQuery === 'undefined') {
1448
1505
  var isValidContainer = this.isValidContainer($parent);
1449
1506
  if (isValidContainer !== null) {
1450
1507
  $parent.removeClass(this.options.row.valid).removeClass(this.options.row.invalid);
1451
-
1452
- if (status === this.STATUS_VALID || $allErrors.length > 1) {
1508
+ if (status === this.STATUS_VALID || numIgnored !== $allErrors.length) {
1453
1509
  $parent.addClass(isValidContainer ? this.options.row.valid : this.options.row.invalid);
1454
1510
  }
1455
1511
  }
@@ -1501,8 +1557,9 @@ if (typeof jQuery === 'undefined') {
1501
1557
  this._submit();
1502
1558
  return this;
1503
1559
  }
1504
- this.disableSubmitButtons(true);
1560
+ this.$form.trigger($.Event(this.options.events.formPreValidate));
1505
1561
 
1562
+ this.disableSubmitButtons(true);
1506
1563
  this._submitIfValid = false;
1507
1564
  for (var field in this.options.fields) {
1508
1565
  this.validateField(field);
@@ -1535,7 +1592,9 @@ if (typeof jQuery === 'undefined') {
1535
1592
  break;
1536
1593
  }
1537
1594
 
1538
- if (fields.length === 0 || !this.options.fields[field] || this.options.fields[field].enabled === false) {
1595
+ if (fields.length === 0 || !this.options.fields[field]
1596
+ || this.options.fields[field].enabled === 'false' || this.options.fields[field].enabled === false)
1597
+ {
1539
1598
  return this;
1540
1599
  }
1541
1600
 
@@ -1546,6 +1605,7 @@ if (typeof jQuery === 'undefined') {
1546
1605
  validators = this.options.fields[field].validators,
1547
1606
  verbose = this.isOptionEnabled(field, 'verbose'),
1548
1607
  validatorName,
1608
+ alias,
1549
1609
  validateResult;
1550
1610
 
1551
1611
  for (var i = 0; i < total; i++) {
@@ -1569,12 +1629,18 @@ if (typeof jQuery === 'undefined') {
1569
1629
  this._onFieldValidated($field, validatorName);
1570
1630
  continue;
1571
1631
  } else if (validators[validatorName].enabled === false) {
1572
- this.updateStatus(updateAll ? field : $field, this.STATUS_VALID, validatorName);
1632
+ // Changed in v0.6.2:
1633
+ // When the field validator is disabled, it should be treated as STATUS_IGNORED instead of STATUS_VALID
1634
+ // By doing that, the field with only disabled and ignored validators will not have success/error class
1635
+ this.updateStatus(updateAll ? field : $field, this.STATUS_IGNORED, validatorName);
1573
1636
  continue;
1574
1637
  }
1575
1638
 
1576
1639
  $field.data(ns + '.result.' + validatorName, this.STATUS_VALIDATING);
1577
- validateResult = FormValidation.Validator[validatorName].validate(this, $field, validators[validatorName]);
1640
+
1641
+ // Check whether or not the validator is just an alias of another
1642
+ alias = validators[validatorName].alias || validatorName;
1643
+ validateResult = FormValidation.Validator[alias].validate(this, $field, validators[validatorName], validatorName);
1578
1644
 
1579
1645
  // validateResult can be a $.Deferred object ...
1580
1646
  if ('object' === typeof validateResult && validateResult.resolve) {
@@ -1621,9 +1687,9 @@ if (typeof jQuery === 'undefined') {
1621
1687
  break;
1622
1688
  }
1623
1689
  }
1624
- // ... or null/undefined
1625
- // to indicate that the field should be ignored for current validation
1626
- else if (null === validateResult || undefined === validateResult) {
1690
+ // ... or null
1691
+ // to indicate that the field should be ignored for current validator
1692
+ else if (null === validateResult) {
1627
1693
  $field.data(ns + '.response.' + validatorName, validateResult);
1628
1694
  this.updateStatus(updateAll ? field : $field, this.STATUS_IGNORED, validatorName);
1629
1695
  }
@@ -1697,7 +1763,7 @@ if (typeof jQuery === 'undefined') {
1697
1763
  * It will remove all error messages, feedback icons and turn off the events
1698
1764
  */
1699
1765
  destroy: function() {
1700
- var ns = this._namespace, i, field, fields, $field, validator, $icon, row;
1766
+ var ns = this._namespace, i, field, fields, $field, validator, $icon, row, alias;
1701
1767
 
1702
1768
  // Destroy the validators first
1703
1769
  for (field in this.options.fields) {
@@ -1713,8 +1779,9 @@ if (typeof jQuery === 'undefined') {
1713
1779
  .removeData(ns + '.dfs.' + validator);
1714
1780
 
1715
1781
  // Destroy the validator
1716
- if ('function' === typeof FormValidation.Validator[validator].destroy) {
1717
- FormValidation.Validator[validator].destroy(this, $field, this.options.fields[field].validators[validator]);
1782
+ alias = this.options.fields[field].validators[validator].alias || validator;
1783
+ if ('function' === typeof FormValidation.Validator[alias].destroy) {
1784
+ FormValidation.Validator[alias].destroy(this, $field, this.options.fields[field].validators[validator], validator);
1718
1785
  }
1719
1786
  }
1720
1787
  }
@@ -2173,8 +2240,10 @@ if (typeof jQuery === 'undefined') {
2173
2240
 
2174
2241
  $.fn.formValidation.Constructor = FormValidation.Base;
2175
2242
 
2176
- // The default options
2177
- // Sorted in alphabetical order
2243
+ // Default message
2244
+ $.fn.formValidation.DEFAULT_MESSAGE = 'This value is not valid';
2245
+
2246
+ // The default options sorted in alphabetical order
2178
2247
  $.fn.formValidation.DEFAULT_OPTIONS = {
2179
2248
  // The first invalid field will be focused automatically
2180
2249
  autoFocus: true,
@@ -2191,6 +2260,7 @@ if (typeof jQuery === 'undefined') {
2191
2260
  events: {
2192
2261
  // Support backward
2193
2262
  formInit: 'init.form.fv',
2263
+ formPreValidate: 'prevalidate.form.fv',
2194
2264
  formError: 'err.form.fv',
2195
2265
  formSuccess: 'success.form.fv',
2196
2266
  fieldAdded: 'added.field.fv',
@@ -2244,7 +2314,7 @@ if (typeof jQuery === 'undefined') {
2244
2314
  locale: 'en_US',
2245
2315
 
2246
2316
  // Default invalid message
2247
- message: 'This value is not valid',
2317
+ message: null,
2248
2318
 
2249
2319
  // The field will not be live validated if its length is less than this number of characters
2250
2320
  threshold: null,
@@ -2264,7 +2334,8 @@ if (typeof jQuery === 'undefined') {
2264
2334
  button: {
2265
2335
  // The submit buttons selector
2266
2336
  // These buttons will be disabled to prevent the valid form from multiple submissions
2267
- selector: '[type="submit"]',
2337
+ // Don't perform validation when clicking on the submit button/input which have formnovalidate attribute
2338
+ selector: '[type="submit"]:not([formnovalidate])',
2268
2339
 
2269
2340
  // The disabled class
2270
2341
  disabled: ''
@@ -2489,8 +2560,8 @@ if (typeof jQuery === 'undefined') {
2489
2560
  * - message: The invalid message
2490
2561
  * @returns {Boolean}
2491
2562
  */
2492
- validate: function(validator, $field, options) {
2493
- var value = validator.getFieldValue($field, 'base64');
2563
+ validate: function(validator, $field, options, validatorName) {
2564
+ var value = validator.getFieldValue($field, validatorName);
2494
2565
  if (value === '') {
2495
2566
  return true;
2496
2567
  }
@@ -2547,16 +2618,13 @@ if (typeof jQuery === 'undefined') {
2547
2618
  * - message: The invalid message
2548
2619
  * @returns {Boolean|Object}
2549
2620
  */
2550
- validate: function(validator, $field, options) {
2551
- var value = validator.getFieldValue($field, 'between');
2621
+ validate: function(validator, $field, options, validatorName) {
2622
+ var value = validator.getFieldValue($field, validatorName);
2552
2623
  if (value === '') {
2553
2624
  return true;
2554
2625
  }
2555
2626
 
2556
2627
  value = this._format(value);
2557
- if (!$.isNumeric(value)) {
2558
- return false;
2559
- }
2560
2628
 
2561
2629
  var locale = validator.getLocale(),
2562
2630
  min = $.isNumeric(options.min) ? options.min : validator.getDynamicOption($field, options.min),
@@ -2564,14 +2632,13 @@ if (typeof jQuery === 'undefined') {
2564
2632
  minValue = this._format(min),
2565
2633
  maxValue = this._format(max);
2566
2634
 
2567
- value = parseFloat(value);
2568
2635
  return (options.inclusive === true || options.inclusive === undefined)
2569
2636
  ? {
2570
- valid: value >= minValue && value <= maxValue,
2637
+ valid: $.isNumeric(value) && parseFloat(value) >= minValue && parseFloat(value) <= maxValue,
2571
2638
  message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].between['default'], [min, max])
2572
2639
  }
2573
2640
  : {
2574
- valid: value > minValue && value < maxValue,
2641
+ valid: $.isNumeric(value) && parseFloat(value) > minValue && parseFloat(value) < maxValue,
2575
2642
  message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].between.notInclusive, [min, max])
2576
2643
  };
2577
2644
  },
@@ -2603,8 +2670,8 @@ if (typeof jQuery === 'undefined') {
2603
2670
  * - message: The invalid message
2604
2671
  * @returns {Object}
2605
2672
  */
2606
- validate: function(validator, $field, options) {
2607
- var value = validator.getFieldValue($field, 'bic');
2673
+ validate: function(validator, $field, options, validatorName) {
2674
+ var value = validator.getFieldValue($field, validatorName);
2608
2675
  if (value === '') {
2609
2676
  return true;
2610
2677
  }
@@ -2625,18 +2692,16 @@ if (typeof jQuery === 'undefined') {
2625
2692
  * validation and an associated message.
2626
2693
  * (4) ajax 400 call handler does the following:
2627
2694
  *
2628
- * bv.updateMessage(field, 'blank', errorMessage);
2629
- * bv.updateStatus(field, 'INVALID');
2695
+ * fv.updateMessage(field, 'blank', errorMessage);
2696
+ * fv.updateStatus(field, 'INVALID', 'blank');
2630
2697
  *
2631
- * @see https://github.com/formvalidation/formvalidation/issues/542
2632
- * @see https://github.com/formvalidation/formvalidation/pull/666
2633
2698
  * @param {FormValidation.Base} validator The validator plugin instance
2634
2699
  * @param {jQuery} $field Field element
2635
2700
  * @param {Object} options Can consist of the following keys:
2636
2701
  * - message: The invalid message
2637
2702
  * @returns {Boolean}
2638
2703
  */
2639
- validate: function(validator, $field, options) {
2704
+ validate: function(validator, $field, options, validatorName) {
2640
2705
  return true;
2641
2706
  }
2642
2707
  };
@@ -2662,17 +2727,17 @@ if (typeof jQuery === 'undefined') {
2662
2727
  * @param {FormValidation.Base} validator The validator plugin instance
2663
2728
  * @param {jQuery} $field Field element
2664
2729
  * @param {Object} options Can consist of the following keys:
2665
- * - callback: The callback method that passes 2 parameters:
2730
+ * - callback: The callback method that passes parameters:
2666
2731
  * callback: function(fieldValue, validator, $field) {
2667
2732
  * // fieldValue is the value of field
2668
- * // validator is instance of BootstrapValidator
2733
+ * // validator is instance of FormValidation.Base
2669
2734
  * // $field is the field element
2670
2735
  * }
2671
2736
  * - message: The invalid message
2672
2737
  * @returns {Deferred}
2673
2738
  */
2674
- validate: function(validator, $field, options) {
2675
- var value = validator.getFieldValue($field, 'callback'),
2739
+ validate: function(validator, $field, options, validatorName) {
2740
+ var value = validator.getFieldValue($field, validatorName),
2676
2741
  dfd = new $.Deferred(),
2677
2742
  result = { valid: true };
2678
2743
 
@@ -2681,7 +2746,7 @@ if (typeof jQuery === 'undefined') {
2681
2746
  result = ('boolean' === typeof response || null === response) ? { valid: response } : response;
2682
2747
  }
2683
2748
 
2684
- dfd.resolve($field, 'callback', result);
2749
+ dfd.resolve($field, validatorName, result);
2685
2750
  return dfd;
2686
2751
  }
2687
2752
  };
@@ -2724,7 +2789,7 @@ if (typeof jQuery === 'undefined') {
2724
2789
  * - message: The invalid message
2725
2790
  * @returns {Object}
2726
2791
  */
2727
- validate: function(validator, $field, options) {
2792
+ validate: function(validator, $field, options, validatorName) {
2728
2793
  var locale = validator.getLocale(),
2729
2794
  ns = validator.getNamespace(),
2730
2795
  numChoices = $field.is('select')
@@ -2846,8 +2911,8 @@ if (typeof jQuery === 'undefined') {
2846
2911
  * - type: The array of valid color types
2847
2912
  * @returns {Boolean}
2848
2913
  */
2849
- validate: function(validator, $field, options) {
2850
- var value = validator.getFieldValue($field, 'color');
2914
+ validate: function(validator, $field, options, validatorName) {
2915
+ var value = validator.getFieldValue($field, validatorName);
2851
2916
  if (value === '') {
2852
2917
  return true;
2853
2918
  }
@@ -2928,8 +2993,8 @@ if (typeof jQuery === 'undefined') {
2928
2993
  * - message: The invalid message
2929
2994
  * @returns {Boolean|Object}
2930
2995
  */
2931
- validate: function(validator, $field, options) {
2932
- var value = validator.getFieldValue($field, 'creditCard');
2996
+ validate: function(validator, $field, options, validatorName) {
2997
+ var value = validator.getFieldValue($field, validatorName);
2933
2998
  if (value === '') {
2934
2999
  return true;
2935
3000
  }
@@ -3030,9 +3095,6 @@ if (typeof jQuery === 'undefined') {
3030
3095
  FormValidation.Validator.cusip = {
3031
3096
  /**
3032
3097
  * Validate a CUSIP number
3033
- * Examples:
3034
- * - Valid: 037833100, 931142103, 14149YAR8, 126650BG6
3035
- * - Invalid: 31430F200, 022615AC2
3036
3098
  *
3037
3099
  * @see http://en.wikipedia.org/wiki/CUSIP
3038
3100
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -3041,8 +3103,8 @@ if (typeof jQuery === 'undefined') {
3041
3103
  * - message: The invalid message
3042
3104
  * @returns {Boolean}
3043
3105
  */
3044
- validate: function(validator, $field, options) {
3045
- var value = validator.getFieldValue($field, 'cusip');
3106
+ validate: function(validator, $field, options, validatorName) {
3107
+ var value = validator.getFieldValue($field, validatorName);
3046
3108
  if (value === '') {
3047
3109
  return true;
3048
3110
  }
@@ -3100,11 +3162,11 @@ if (typeof jQuery === 'undefined') {
3100
3162
  * @param {Object} options Consists of the following key:
3101
3163
  * - creditCardField: The credit card number field
3102
3164
  */
3103
- init: function(validator, $field, options) {
3165
+ init: function(validator, $field, options, validatorName) {
3104
3166
  if (options.creditCardField) {
3105
3167
  var creditCardField = validator.getFieldElements(options.creditCardField);
3106
- validator.onLiveChange(creditCardField, 'live_cvv', function() {
3107
- var status = validator.getStatus($field, 'cvv');
3168
+ validator.onLiveChange(creditCardField, 'live_' + validatorName, function() {
3169
+ var status = validator.getStatus($field, validatorName);
3108
3170
  if (status !== validator.STATUS_NOT_VALIDATED) {
3109
3171
  validator.revalidateField($field);
3110
3172
  }
@@ -3120,10 +3182,10 @@ if (typeof jQuery === 'undefined') {
3120
3182
  * @param {Object} options Consists of the following key:
3121
3183
  * - creditCardField: The credit card number field
3122
3184
  */
3123
- destroy: function(validator, $field, options) {
3185
+ destroy: function(validator, $field, options, validatorName) {
3124
3186
  if (options.creditCardField) {
3125
3187
  var creditCardField = validator.getFieldElements(options.creditCardField);
3126
- validator.offLiveChange(creditCardField, 'live_cvv');
3188
+ validator.offLiveChange(creditCardField, 'live_' + validatorName);
3127
3189
  }
3128
3190
  },
3129
3191
 
@@ -3137,8 +3199,8 @@ if (typeof jQuery === 'undefined') {
3137
3199
  * - message: The invalid message
3138
3200
  * @returns {Boolean}
3139
3201
  */
3140
- validate: function(validator, $field, options) {
3141
- var value = validator.getFieldValue($field, 'cvv');
3202
+ validate: function(validator, $field, options, validatorName) {
3203
+ var value = validator.getFieldValue($field, validatorName);
3142
3204
  if (value === '') {
3143
3205
  return true;
3144
3206
  }
@@ -3156,7 +3218,7 @@ if (typeof jQuery === 'undefined') {
3156
3218
  if (creditCard === '') {
3157
3219
  return true;
3158
3220
  }
3159
-
3221
+
3160
3222
  creditCard = creditCard.replace(/\D/g, '');
3161
3223
 
3162
3224
  // Supported credit card types
@@ -3273,8 +3335,8 @@ if (typeof jQuery === 'undefined') {
3273
3335
  * ii) date, time and A (indicating AM or PM)
3274
3336
  * @returns {Boolean|Object}
3275
3337
  */
3276
- validate: function(validator, $field, options) {
3277
- var value = validator.getFieldValue($field, 'date');
3338
+ validate: function(validator, $field, options, validatorName) {
3339
+ var value = validator.getFieldValue($field, validatorName);
3278
3340
  if (value === '') {
3279
3341
  return true;
3280
3342
  }
@@ -3466,6 +3528,7 @@ if (typeof jQuery === 'undefined') {
3466
3528
 
3467
3529
  return {
3468
3530
  valid: valid,
3531
+ date: date,
3469
3532
  message: message
3470
3533
  };
3471
3534
  },
@@ -3614,12 +3677,12 @@ if (typeof jQuery === 'undefined') {
3614
3677
  * @param {Object} options Consists of the following key:
3615
3678
  * - field: The name of field that will be used to compare with current one
3616
3679
  */
3617
- init: function(validator, $field, options) {
3680
+ init: function(validator, $field, options, validatorName) {
3618
3681
  var fields = options.field.split(',');
3619
3682
  for (var i = 0; i < fields.length; i++) {
3620
3683
  var compareWith = validator.getFieldElements(fields[i]);
3621
- validator.onLiveChange(compareWith, 'live_different', function() {
3622
- var status = validator.getStatus($field, 'different');
3684
+ validator.onLiveChange(compareWith, 'live_' + validatorName, function() {
3685
+ var status = validator.getStatus($field, validatorName);
3623
3686
  if (status !== validator.STATUS_NOT_VALIDATED) {
3624
3687
  validator.revalidateField($field);
3625
3688
  }
@@ -3635,11 +3698,11 @@ if (typeof jQuery === 'undefined') {
3635
3698
  * @param {Object} options Consists of the following key:
3636
3699
  * - field: The name of field that will be used to compare with current one
3637
3700
  */
3638
- destroy: function(validator, $field, options) {
3701
+ destroy: function(validator, $field, options, validatorName) {
3639
3702
  var fields = options.field.split(',');
3640
3703
  for (var i = 0; i < fields.length; i++) {
3641
3704
  var compareWith = validator.getFieldElements(fields[i]);
3642
- validator.offLiveChange(compareWith, 'live_different');
3705
+ validator.offLiveChange(compareWith, 'live_' + validatorName);
3643
3706
  }
3644
3707
  },
3645
3708
 
@@ -3653,8 +3716,8 @@ if (typeof jQuery === 'undefined') {
3653
3716
  * - message: The invalid message
3654
3717
  * @returns {Boolean}
3655
3718
  */
3656
- validate: function(validator, $field, options) {
3657
- var value = validator.getFieldValue($field, 'different');
3719
+ validate: function(validator, $field, options, validatorName) {
3720
+ var value = validator.getFieldValue($field, validatorName);
3658
3721
  if (value === '') {
3659
3722
  return true;
3660
3723
  }
@@ -3668,11 +3731,11 @@ if (typeof jQuery === 'undefined') {
3668
3731
  continue;
3669
3732
  }
3670
3733
 
3671
- var compareValue = validator.getFieldValue(compareWith, 'different');
3734
+ var compareValue = validator.getFieldValue(compareWith, validatorName);
3672
3735
  if (value === compareValue) {
3673
3736
  isValid = false;
3674
3737
  } else if (compareValue !== '') {
3675
- validator.updateStatus(compareWith, validator.STATUS_VALID, 'different');
3738
+ validator.updateStatus(compareWith, validator.STATUS_VALID, validatorName);
3676
3739
  }
3677
3740
  }
3678
3741
 
@@ -3698,8 +3761,8 @@ if (typeof jQuery === 'undefined') {
3698
3761
  * @param {Object} [options]
3699
3762
  * @returns {Boolean}
3700
3763
  */
3701
- validate: function(validator, $field, options) {
3702
- var value = validator.getFieldValue($field, 'digits');
3764
+ validate: function(validator, $field, options, validatorName) {
3765
+ var value = validator.getFieldValue($field, validatorName);
3703
3766
  if (value === '') {
3704
3767
  return true;
3705
3768
  }
@@ -3720,9 +3783,6 @@ if (typeof jQuery === 'undefined') {
3720
3783
  FormValidation.Validator.ean = {
3721
3784
  /**
3722
3785
  * Validate EAN (International Article Number)
3723
- * Examples:
3724
- * - Valid: 73513537, 9780471117094, 4006381333931
3725
- * - Invalid: 73513536
3726
3786
  *
3727
3787
  * @see http://en.wikipedia.org/wiki/European_Article_Number
3728
3788
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -3731,8 +3791,8 @@ if (typeof jQuery === 'undefined') {
3731
3791
  * - message: The invalid message
3732
3792
  * @returns {Boolean}
3733
3793
  */
3734
- validate: function(validator, $field, options) {
3735
- var value = validator.getFieldValue($field, 'ean');
3794
+ validate: function(validator, $field, options, validatorName) {
3795
+ var value = validator.getFieldValue($field, validatorName);
3736
3796
  if (value === '') {
3737
3797
  return true;
3738
3798
  }
@@ -3790,8 +3850,8 @@ if (typeof jQuery === 'undefined') {
3790
3850
  * - message: The invalid message
3791
3851
  * @returns {Object|Boolean}
3792
3852
  */
3793
- validate: function(validator, $field, options) {
3794
- var value = validator.getFieldValue($field, 'ein');
3853
+ validate: function(validator, $field, options, validatorName) {
3854
+ var value = validator.getFieldValue($field, validatorName);
3795
3855
  if (value === '') {
3796
3856
  return true;
3797
3857
  }
@@ -3844,8 +3904,8 @@ if (typeof jQuery === 'undefined') {
3844
3904
  * - separator: Regex for character or characters expected as separator between addresses; default is comma /[,;]/, i.e. comma or semicolon.
3845
3905
  * @returns {Boolean}
3846
3906
  */
3847
- validate: function(validator, $field, options) {
3848
- var value = validator.getFieldValue($field, 'emailAddress');
3907
+ validate: function(validator, $field, options, validatorName) {
3908
+ var value = validator.getFieldValue($field, validatorName);
3849
3909
  if (value === '') {
3850
3910
  return true;
3851
3911
  }
@@ -3944,8 +4004,8 @@ if (typeof jQuery === 'undefined') {
3944
4004
  * - type: The allowed MIME type, separated by a comma
3945
4005
  * @returns {Boolean}
3946
4006
  */
3947
- validate: function(validator, $field, options) {
3948
- var value = validator.getFieldValue($field, 'file');
4007
+ validate: function(validator, $field, options, validatorName) {
4008
+ var value = validator.getFieldValue($field, validatorName);
3949
4009
  if (value === '') {
3950
4010
  return true;
3951
4011
  }
@@ -4042,29 +4102,25 @@ if (typeof jQuery === 'undefined') {
4042
4102
  * - message: The invalid message
4043
4103
  * @returns {Boolean|Object}
4044
4104
  */
4045
- validate: function(validator, $field, options) {
4046
- var value = validator.getFieldValue($field, 'greaterThan');
4105
+ validate: function(validator, $field, options, validatorName) {
4106
+ var value = validator.getFieldValue($field, validatorName);
4047
4107
  if (value === '') {
4048
4108
  return true;
4049
4109
  }
4050
-
4110
+
4051
4111
  value = this._format(value);
4052
- if (!$.isNumeric(value)) {
4053
- return false;
4054
- }
4055
4112
 
4056
4113
  var locale = validator.getLocale(),
4057
4114
  compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
4058
4115
  compareToValue = this._format(compareTo);
4059
4116
 
4060
- value = parseFloat(value);
4061
4117
  return (options.inclusive === true || options.inclusive === undefined)
4062
4118
  ? {
4063
- valid: value >= compareToValue,
4119
+ valid: $.isNumeric(value) && parseFloat(value) >= compareToValue,
4064
4120
  message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].greaterThan['default'], compareTo)
4065
4121
  }
4066
4122
  : {
4067
- valid: value > compareToValue,
4123
+ valid: $.isNumeric(value) && parseFloat(value) > compareToValue,
4068
4124
  message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].greaterThan.notInclusive, compareTo)
4069
4125
  };
4070
4126
  },
@@ -4086,9 +4142,6 @@ if (typeof jQuery === 'undefined') {
4086
4142
  FormValidation.Validator.grid = {
4087
4143
  /**
4088
4144
  * Validate GRId (Global Release Identifier)
4089
- * Examples:
4090
- * - Valid: A12425GABC1234002M, A1-2425G-ABC1234002-M, A1 2425G ABC1234002 M, Grid:A1-2425G-ABC1234002-M
4091
- * - Invalid: A1-2425G-ABC1234002-Q
4092
4145
  *
4093
4146
  * @see http://en.wikipedia.org/wiki/Global_Release_Identifier
4094
4147
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -4097,8 +4150,8 @@ if (typeof jQuery === 'undefined') {
4097
4150
  * - message: The invalid message
4098
4151
  * @returns {Boolean}
4099
4152
  */
4100
- validate: function(validator, $field, options) {
4101
- var value = validator.getFieldValue($field, 'grid');
4153
+ validate: function(validator, $field, options, validatorName) {
4154
+ var value = validator.getFieldValue($field, validatorName);
4102
4155
  if (value === '') {
4103
4156
  return true;
4104
4157
  }
@@ -4134,8 +4187,8 @@ if (typeof jQuery === 'undefined') {
4134
4187
  * - message: The invalid message
4135
4188
  * @returns {Boolean}
4136
4189
  */
4137
- validate: function(validator, $field, options) {
4138
- var value = validator.getFieldValue($field, 'hex');
4190
+ validate: function(validator, $field, options, validatorName) {
4191
+ var value = validator.getFieldValue($field, validatorName);
4139
4192
  if (value === '') {
4140
4193
  return true;
4141
4194
  }
@@ -4227,9 +4280,11 @@ if (typeof jQuery === 'undefined') {
4227
4280
  SK: 'Slovakia',
4228
4281
  SM: 'San Marino',
4229
4282
  SN: 'Senegal',
4283
+ TL: 'East Timor',
4230
4284
  TN: 'Tunisia',
4231
4285
  TR: 'Turkey',
4232
- VG: 'Virgin Islands, British'
4286
+ VG: 'Virgin Islands, British',
4287
+ XK: 'Republic of Kosovo'
4233
4288
  }
4234
4289
  }
4235
4290
  }
@@ -4238,7 +4293,8 @@ if (typeof jQuery === 'undefined') {
4238
4293
  FormValidation.Validator.iban = {
4239
4294
  html5Attributes: {
4240
4295
  message: 'message',
4241
- country: 'country'
4296
+ country: 'country',
4297
+ sepa: 'sepa'
4242
4298
  },
4243
4299
 
4244
4300
  // http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf
@@ -4320,11 +4376,21 @@ if (typeof jQuery === 'undefined') {
4320
4376
  SK: 'SK[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}', // Slovakia
4321
4377
  SM: 'SM[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', // San Marino
4322
4378
  SN: 'SN[0-9]{2}[A-Z]{1}[0-9]{23}', // Senegal
4379
+ TL: 'TL38[0-9]{3}[0-9]{14}[0-9]{2}', // East Timor
4323
4380
  TN: 'TN59[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', // Tunisia
4324
4381
  TR: 'TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}', // Turkey
4325
- VG: 'VG[0-9]{2}[A-Z]{4}[0-9]{16}' // Virgin Islands, British
4382
+ VG: 'VG[0-9]{2}[A-Z]{4}[0-9]{16}', // Virgin Islands, British
4383
+ XK: 'XK[0-9]{2}[0-9]{4}[0-9]{10}[0-9]{2}' // Republic of Kosovo
4326
4384
  },
4327
4385
 
4386
+ // List of SEPA country codes
4387
+ SEPA_COUNTRIES: [
4388
+ 'AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES',
4389
+ 'FI', 'FR', 'GB', 'GI', 'GR', 'HR', 'HU', 'IE', 'IS', 'IT',
4390
+ 'LI', 'LT', 'LU', 'LV', 'MC', 'MT', 'NL', 'NO', 'PL', 'PT',
4391
+ 'RO', 'SE', 'SI', 'SK', 'SM'
4392
+ ],
4393
+
4328
4394
  /**
4329
4395
  * Validate an International Bank Account Number (IBAN)
4330
4396
  * To test it, take the sample IBAN from
@@ -4339,10 +4405,12 @@ if (typeof jQuery === 'undefined') {
4339
4405
  * - Name of field which its value defines the country code
4340
4406
  * - Name of callback function that returns the country code
4341
4407
  * - A callback function that returns the country code
4408
+ * - sepa: Set it to true (false) to indicate that the IBAN number must be (not be) from SEPA countries
4409
+ * By default, this option is not defined
4342
4410
  * @returns {Boolean|Object}
4343
4411
  */
4344
- validate: function(validator, $field, options) {
4345
- var value = validator.getFieldValue($field, 'iban');
4412
+ validate: function(validator, $field, options, validatorName) {
4413
+ var value = validator.getFieldValue($field, validatorName);
4346
4414
  if (value === '') {
4347
4415
  return true;
4348
4416
  }
@@ -4358,7 +4426,17 @@ if (typeof jQuery === 'undefined') {
4358
4426
 
4359
4427
  var locale = validator.getLocale();
4360
4428
  if (!this.REGEX[country]) {
4361
- return true;
4429
+ return false;
4430
+ }
4431
+
4432
+ // Check whether or not the sepa option is enabled
4433
+ if (typeof options.sepa !== undefined) {
4434
+ var isSepaCountry = $.inArray(country, this.SEPA_COUNTRIES) !== -1;
4435
+ if (((options.sepa === 'true' || options.sepa === true) && !isSepaCountry)
4436
+ || ((options.sepa === 'false' || options.sepa === false) && isSepaCountry))
4437
+ {
4438
+ return false;
4439
+ }
4362
4440
  }
4363
4441
 
4364
4442
  if (!(new RegExp('^' + this.REGEX[country] + '$')).test(value)) {
@@ -4456,10 +4534,10 @@ if (typeof jQuery === 'undefined') {
4456
4534
  * - Name of field which its value defines the country code
4457
4535
  * - Name of callback function that returns the country code
4458
4536
  * - A callback function that returns the country code
4459
- * @returns {Boolean|Object}
4537
+ * @returns {Object}
4460
4538
  */
4461
- validate: function(validator, $field, options) {
4462
- var value = validator.getFieldValue($field, 'id');
4539
+ validate: function(validator, $field, options, validatorName) {
4540
+ var value = validator.getFieldValue($field, validatorName);
4463
4541
  if (value === '') {
4464
4542
  return true;
4465
4543
  }
@@ -4477,13 +4555,12 @@ if (typeof jQuery === 'undefined') {
4477
4555
  return true;
4478
4556
  }
4479
4557
 
4480
- var method = ['_', country.toLowerCase()].join('');
4481
- return this[method](value)
4482
- ? true
4483
- : {
4484
- valid: false,
4485
- message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].id.country, FormValidation.I18n[locale].id.countries[country.toUpperCase()])
4486
- };
4558
+ var method = ['_', country.toLowerCase()].join(''),
4559
+ result = this[method](value);
4560
+ result = (result === true || result === false) ? { valid: result } : result;
4561
+ result.message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].id.country, FormValidation.I18n[locale].id.countries[country.toUpperCase()]);
4562
+
4563
+ return result;
4487
4564
  },
4488
4565
 
4489
4566
  /**
@@ -4576,9 +4653,6 @@ if (typeof jQuery === 'undefined') {
4576
4653
 
4577
4654
  /**
4578
4655
  * Validate Bulgarian national identification number (EGN)
4579
- * Examples:
4580
- * - Valid: 7523169263, 8032056031, 803205 603 1, 8001010008, 7501020018, 7552010005, 7542011030
4581
- * - Invalid: 8019010008
4582
4656
  *
4583
4657
  * @see http://en.wikipedia.org/wiki/Uniform_civil_number
4584
4658
  * @param {String} value The ID
@@ -4616,9 +4690,6 @@ if (typeof jQuery === 'undefined') {
4616
4690
 
4617
4691
  /**
4618
4692
  * Validate Brazilian national identification number (CPF)
4619
- * Examples:
4620
- * - Valid: 39053344705, 390.533.447-05, 111.444.777-35
4621
- * - Invalid: 231.002.999-00
4622
4693
  *
4623
4694
  * @see http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas
4624
4695
  * @param {String} value The ID
@@ -4657,8 +4728,6 @@ if (typeof jQuery === 'undefined') {
4657
4728
 
4658
4729
  /**
4659
4730
  * Validate Swiss Social Security Number (AHV-Nr/No AVS)
4660
- * Examples:
4661
- * - Valid: 756.1234.5678.95, 7561234567895
4662
4731
  *
4663
4732
  * @see http://en.wikipedia.org/wiki/National_identification_number#Switzerland
4664
4733
  * @see http://www.bsv.admin.ch/themen/ahv/00011/02185/index.html?lang=de
@@ -4682,8 +4751,6 @@ if (typeof jQuery === 'undefined') {
4682
4751
 
4683
4752
  /**
4684
4753
  * Validate Chilean national identification number (RUN/RUT)
4685
- * Examples:
4686
- * - Valid: 76086428-5, 22060449-7, 12531909-2
4687
4754
  *
4688
4755
  * @see http://en.wikipedia.org/wiki/National_identification_number#Chile
4689
4756
  * @see https://palena.sii.cl/cvc/dte/ee_empresas_emisoras.html for samples
@@ -4742,7 +4809,7 @@ if (typeof jQuery === 'undefined') {
4742
4809
  if (!/^\d{15}$/.test(value) && !/^\d{17}[\dXx]{1}$/.test(value)) {
4743
4810
  return false;
4744
4811
  }
4745
-
4812
+
4746
4813
  // Check China PR Administrative division code
4747
4814
  var adminDivisionCodes = {
4748
4815
  11: {
@@ -5196,11 +5263,11 @@ if (typeof jQuery === 'undefined') {
5196
5263
  81: { 0: [0] },
5197
5264
  82: { 0: [0] }
5198
5265
  };
5199
-
5266
+
5200
5267
  var provincial = parseInt(value.substr(0, 2), 10),
5201
5268
  prefectural = parseInt(value.substr(2, 2), 10),
5202
5269
  county = parseInt(value.substr(4, 2), 10);
5203
-
5270
+
5204
5271
  if (!adminDivisionCodes[provincial] || !adminDivisionCodes[provincial][prefectural]) {
5205
5272
  return false;
5206
5273
  }
@@ -5218,12 +5285,12 @@ if (typeof jQuery === 'undefined') {
5218
5285
  if (!inRange) {
5219
5286
  return false;
5220
5287
  }
5221
-
5288
+
5222
5289
  // Check date of birth
5223
5290
  var dob;
5224
5291
  if (value.length === 18) {
5225
5292
  dob = value.substr(6, 8);
5226
- } else /* length == 15 */ {
5293
+ } else /* length == 15 */ {
5227
5294
  dob = '19' + value.substr(6, 6);
5228
5295
  }
5229
5296
  var year = parseInt(dob.substr(0, 4), 10),
@@ -5232,7 +5299,7 @@ if (typeof jQuery === 'undefined') {
5232
5299
  if (!FormValidation.Helper.date(year, month, day)) {
5233
5300
  return false;
5234
5301
  }
5235
-
5302
+
5236
5303
  // Check checksum (18-digit system only)
5237
5304
  if (value.length === 18) {
5238
5305
  var sum = 0,
@@ -5244,15 +5311,12 @@ if (typeof jQuery === 'undefined') {
5244
5311
  var checksum = (value.charAt(17).toUpperCase() !== 'X') ? parseInt(value.charAt(17), 10) : 10;
5245
5312
  return checksum === sum;
5246
5313
  }
5247
-
5314
+
5248
5315
  return true;
5249
5316
  },
5250
-
5317
+
5251
5318
  /**
5252
5319
  * Validate Czech national identification number (RC)
5253
- * Examples:
5254
- * - Valid: 7103192745, 991231123
5255
- * - Invalid: 1103492745, 590312123
5256
5320
  *
5257
5321
  * @param {String} value The ID
5258
5322
  * @returns {Boolean}
@@ -5293,9 +5357,6 @@ if (typeof jQuery === 'undefined') {
5293
5357
 
5294
5358
  /**
5295
5359
  * Validate Danish Personal Identification number (CPR)
5296
- * Examples:
5297
- * - Valid: 2110625629, 211062-5629
5298
- * - Invalid: 511062-5629
5299
5360
  *
5300
5361
  * @see https://en.wikipedia.org/wiki/Personal_identification_number_(Denmark)
5301
5362
  * @param {String} value The ID
@@ -5328,8 +5389,6 @@ if (typeof jQuery === 'undefined') {
5328
5389
 
5329
5390
  /**
5330
5391
  * Validate Estonian Personal Identification Code (isikukood)
5331
- * Examples:
5332
- * - Valid: 37605030299
5333
5392
  *
5334
5393
  * @see http://et.wikipedia.org/wiki/Isikukood
5335
5394
  * @param {String} value The ID
@@ -5342,22 +5401,11 @@ if (typeof jQuery === 'undefined') {
5342
5401
 
5343
5402
  /**
5344
5403
  * Validate Spanish personal identity code (DNI)
5345
- * Support i) DNI (for Spanish citizens), ii) NIE (for foreign people)
5346
- * and iii) CIF (for legal entities)
5347
- *
5348
- * Examples:
5349
- * - Valid:
5350
- * i) 54362315K, 54362315-K
5351
- * ii) X2482300W, X-2482300W, X-2482300-W
5352
- * iii) A58818501, A-58818501
5353
- * - Invalid:
5354
- * i) 54362315Z
5355
- * ii) X-2482300A
5356
- * iii) K58818501, G58818507
5404
+ * Support DNI (for Spanish citizens), NIE (for foreign people) and CIF (for legal entities)
5357
5405
  *
5358
5406
  * @see https://en.wikipedia.org/wiki/National_identification_number#Spain
5359
5407
  * @param {String} value The ID
5360
- * @returns {Boolean}
5408
+ * @returns {Boolean|Object}
5361
5409
  */
5362
5410
  _es: function(value) {
5363
5411
  var isDNI = /^[0-9]{8}[-]{0,1}[A-HJ-NP-TV-Z]$/.test(value),
@@ -5368,19 +5416,25 @@ if (typeof jQuery === 'undefined') {
5368
5416
  }
5369
5417
 
5370
5418
  value = value.replace(/-/g, '');
5371
- var check;
5419
+ var check, type, isValid = true;
5372
5420
  if (isDNI || isNIE) {
5421
+ type = 'DNI';
5373
5422
  var index = 'XYZ'.indexOf(value.charAt(0));
5374
5423
  if (index !== -1) {
5375
5424
  // It is NIE number
5376
5425
  value = index + value.substr(1) + '';
5426
+ type = 'NIE';
5377
5427
  }
5378
5428
 
5379
5429
  check = parseInt(value.substr(0, 8), 10);
5380
5430
  check = 'TRWAGMYFPDXBNJZSQVHLCKE'[check % 23];
5381
- return (check === value.substr(8, 1));
5431
+ return {
5432
+ valid: (check === value.substr(8, 1)),
5433
+ type: type
5434
+ };
5382
5435
  } else {
5383
5436
  check = value.substr(1, 7);
5437
+ type = 'CIF';
5384
5438
  var letter = value[0],
5385
5439
  control = value.substr(-1),
5386
5440
  sum = 0;
@@ -5407,25 +5461,27 @@ if (typeof jQuery === 'undefined') {
5407
5461
  if (lastDigit !== 0) {
5408
5462
  lastDigit = 10 - lastDigit;
5409
5463
  }
5410
-
5464
+
5411
5465
  if ('KQS'.indexOf(letter) !== -1) {
5412
5466
  // If the CIF starts with a K, Q or S, the control digit must be a letter
5413
- return (control === 'JABCDEFGHI'[lastDigit]);
5467
+ isValid = (control === 'JABCDEFGHI'[lastDigit]);
5414
5468
  } else if ('ABEH'.indexOf(letter) !== -1) {
5415
5469
  // If it starts with A, B, E or H, it has to be a number
5416
- return (control === ('' + lastDigit));
5470
+ isValid = (control === ('' + lastDigit));
5417
5471
  } else {
5418
5472
  // In any other case, it doesn't matter
5419
- return (control === ('' + lastDigit) || control === 'JABCDEFGHI'[lastDigit]);
5473
+ isValid = (control === ('' + lastDigit) || control === 'JABCDEFGHI'[lastDigit]);
5420
5474
  }
5475
+
5476
+ return {
5477
+ valid: isValid,
5478
+ type: type
5479
+ };
5421
5480
  }
5422
5481
  },
5423
5482
 
5424
5483
  /**
5425
5484
  * Validate Finnish Personal Identity Code (HETU)
5426
- * Examples:
5427
- * - Valid: 311280-888Y, 131052-308T
5428
- * - Invalid: 131052-308U, 310252-308Y
5429
5485
  *
5430
5486
  * @param {String} value The ID
5431
5487
  * @returns {Boolean}
@@ -5459,9 +5515,6 @@ if (typeof jQuery === 'undefined') {
5459
5515
 
5460
5516
  /**
5461
5517
  * Validate Croatian personal identification number (OIB)
5462
- * Examples:
5463
- * - Valid: 33392005961
5464
- * - Invalid: 33392005962
5465
5518
  *
5466
5519
  * @param {String} value The ID
5467
5520
  * @returns {Boolean}
@@ -5475,9 +5528,6 @@ if (typeof jQuery === 'undefined') {
5475
5528
 
5476
5529
  /**
5477
5530
  * Validate Irish Personal Public Service Number (PPS)
5478
- * Examples:
5479
- * - Valid: 6433435F, 6433435FT, 6433435FW, 6433435OA, 6433435IH, 1234567TW, 1234567FA
5480
- * - Invalid: 6433435E, 6433435VH
5481
5531
  *
5482
5532
  * @see https://en.wikipedia.org/wiki/Personal_Public_Service_Number
5483
5533
  * @param {String} value The ID
@@ -5513,10 +5563,8 @@ if (typeof jQuery === 'undefined') {
5513
5563
 
5514
5564
  /**
5515
5565
  * Validate Iceland national identification number (Kennitala)
5516
- * Examples:
5517
- * - Valid: 120174-3399, 1201743399, 0902862349
5518
5566
  *
5519
- * @see http://en.wikipedia.org/wiki/Kennitala
5567
+ * @see http://en.wikipedia.org/wiki/Kennitala
5520
5568
  * @param {String} value The ID
5521
5569
  * @returns {Boolean}
5522
5570
  */
@@ -5546,9 +5594,6 @@ if (typeof jQuery === 'undefined') {
5546
5594
 
5547
5595
  /**
5548
5596
  * Validate Lithuanian Personal Code (Asmens kodas)
5549
- * Examples:
5550
- * - Valid: 38703181745
5551
- * - Invalid: 38703181746, 78703181745, 38703421745
5552
5597
  *
5553
5598
  * @see http://en.wikipedia.org/wiki/National_identification_number#Lithuania
5554
5599
  * @see http://www.adomas.org/midi2007/pcode.html
@@ -5595,9 +5640,6 @@ if (typeof jQuery === 'undefined') {
5595
5640
 
5596
5641
  /**
5597
5642
  * Validate Latvian Personal Code (Personas kods)
5598
- * Examples:
5599
- * - Valid: 161175-19997, 16117519997
5600
- * - Invalid: 161375-19997
5601
5643
  *
5602
5644
  * @see http://laacz.lv/2006/11/25/pk-parbaudes-algoritms/
5603
5645
  * @param {String} value The ID
@@ -5630,16 +5672,17 @@ if (typeof jQuery === 'undefined') {
5630
5672
 
5631
5673
  /**
5632
5674
  * Validate Dutch national identification number (BSN)
5633
- * Examples:
5634
- * - Valid: 111222333, 941331490, 9413.31.490
5635
- * - Invalid: 111252333
5636
5675
  *
5637
5676
  * @see https://nl.wikipedia.org/wiki/Burgerservicenummer
5638
5677
  * @param {String} value The ID
5639
5678
  * @returns {Boolean}
5640
5679
  */
5641
5680
  _nl: function(value) {
5642
- while (value.length < 9) {
5681
+ if (value.length < 8) {
5682
+ return false;
5683
+ }
5684
+
5685
+ if (value.length === 8) {
5643
5686
  value = '0' + value;
5644
5687
  }
5645
5688
  if (!/^[0-9]{4}[.]{0,1}[0-9]{2}[.]{0,1}[0-9]{3}$/.test(value)) {
@@ -5660,10 +5703,10 @@ if (typeof jQuery === 'undefined') {
5660
5703
  }
5661
5704
  return (sum + '' === value.charAt(length - 1));
5662
5705
  },
5663
-
5706
+
5664
5707
  /**
5665
5708
  * Validate Poland citizen number (PESEL)
5666
- *
5709
+ *
5667
5710
  * @see http://en.wikipedia.org/wiki/National_identification_number#Poland
5668
5711
  * @see http://en.wikipedia.org/wiki/PESEL
5669
5712
  * @param {String} value The ID
@@ -5692,9 +5735,6 @@ if (typeof jQuery === 'undefined') {
5692
5735
 
5693
5736
  /**
5694
5737
  * Validate Romanian numerical personal code (CNP)
5695
- * Examples:
5696
- * - Valid: 1630615123457, 1800101221144
5697
- * - Invalid: 8800101221144, 1632215123457, 1630615123458
5698
5738
  *
5699
5739
  * @see http://en.wikipedia.org/wiki/National_identification_number#Romania
5700
5740
  * @param {String} value The ID
@@ -5748,9 +5788,6 @@ if (typeof jQuery === 'undefined') {
5748
5788
 
5749
5789
  /**
5750
5790
  * Validate Swedish personal identity number (personnummer)
5751
- * Examples:
5752
- * - Valid: 8112289874, 811228-9874, 811228+9874
5753
- * - Invalid: 811228-9873
5754
5791
  *
5755
5792
  * @see http://en.wikipedia.org/wiki/Personal_identity_number_(Sweden)
5756
5793
  * @param {String} value The ID
@@ -5775,9 +5812,6 @@ if (typeof jQuery === 'undefined') {
5775
5812
 
5776
5813
  /**
5777
5814
  * Validate Slovak national identifier number (RC)
5778
- * Examples:
5779
- * - Valid: 7103192745, 991231123
5780
- * - Invalid: 7103192746, 1103492745
5781
5815
  *
5782
5816
  * @param {String} value The ID
5783
5817
  * @returns {Boolean}
@@ -5800,9 +5834,6 @@ if (typeof jQuery === 'undefined') {
5800
5834
 
5801
5835
  /**
5802
5836
  * Validate Thailand citizen number
5803
- * Examples:
5804
- * - Valid: 7145620509547, 3688699975685, 2368719339716
5805
- * - Invalid: 1100800092310
5806
5837
  *
5807
5838
  * @see http://en.wikipedia.org/wiki/National_identification_number#Thailand
5808
5839
  * @param {String} value The ID
@@ -5823,9 +5854,6 @@ if (typeof jQuery === 'undefined') {
5823
5854
 
5824
5855
  /**
5825
5856
  * Validate South African ID
5826
- * Example:
5827
- * - Valid: 8001015009087
5828
- * - Invalid: 8001015009287, 8001015009086
5829
5857
  *
5830
5858
  * @see http://en.wikipedia.org/wiki/National_identification_number#South_Africa
5831
5859
  * @param {String} value The ID
@@ -5873,10 +5901,10 @@ if (typeof jQuery === 'undefined') {
5873
5901
  * @param {Object} options Consists of the following key:
5874
5902
  * - field: The name of field that will be used to compare with current one
5875
5903
  */
5876
- init: function(validator, $field, options) {
5904
+ init: function(validator, $field, options, validatorName) {
5877
5905
  var compareWith = validator.getFieldElements(options.field);
5878
- validator.onLiveChange(compareWith, 'live_identical', function() {
5879
- var status = validator.getStatus($field, 'identical');
5906
+ validator.onLiveChange(compareWith, 'live_' + validatorName, function() {
5907
+ var status = validator.getStatus($field, validatorName);
5880
5908
  if (status !== validator.STATUS_NOT_VALIDATED) {
5881
5909
  validator.revalidateField($field);
5882
5910
  }
@@ -5891,9 +5919,9 @@ if (typeof jQuery === 'undefined') {
5891
5919
  * @param {Object} options Consists of the following key:
5892
5920
  * - field: The name of field that will be used to compare with current one
5893
5921
  */
5894
- destroy: function(validator, $field, options) {
5922
+ destroy: function(validator, $field, options, validatorName) {
5895
5923
  var compareWith = validator.getFieldElements(options.field);
5896
- validator.offLiveChange(compareWith, 'live_identical');
5924
+ validator.offLiveChange(compareWith, 'live_' + validatorName);
5897
5925
  },
5898
5926
 
5899
5927
  /**
@@ -5905,16 +5933,16 @@ if (typeof jQuery === 'undefined') {
5905
5933
  * - field: The name of field that will be used to compare with current one
5906
5934
  * @returns {Boolean}
5907
5935
  */
5908
- validate: function(validator, $field, options) {
5909
- var value = validator.getFieldValue($field, 'identical'),
5936
+ validate: function(validator, $field, options, validatorName) {
5937
+ var value = validator.getFieldValue($field, validatorName),
5910
5938
  compareWith = validator.getFieldElements(options.field);
5911
5939
  if (compareWith === null || compareWith.length === 0) {
5912
5940
  return true;
5913
5941
  }
5914
5942
 
5915
- var compareValue = validator.getFieldValue(compareWith, 'identical');
5943
+ var compareValue = validator.getFieldValue(compareWith, validatorName);
5916
5944
  if (value === compareValue) {
5917
- validator.updateStatus(compareWith, validator.STATUS_VALID, 'identical');
5945
+ validator.updateStatus(compareWith, validator.STATUS_VALID, validatorName);
5918
5946
  return true;
5919
5947
  }
5920
5948
 
@@ -5934,9 +5962,6 @@ if (typeof jQuery === 'undefined') {
5934
5962
  FormValidation.Validator.imei = {
5935
5963
  /**
5936
5964
  * Validate IMEI (International Mobile Station Equipment Identity)
5937
- * Examples:
5938
- * - Valid: 35-209900-176148-1, 35-209900-176148-23, 3568680000414120, 490154203237518
5939
- * - Invalid: 490154203237517
5940
5965
  *
5941
5966
  * @see http://en.wikipedia.org/wiki/International_Mobile_Station_Equipment_Identity
5942
5967
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -5945,8 +5970,8 @@ if (typeof jQuery === 'undefined') {
5945
5970
  * - message: The invalid message
5946
5971
  * @returns {Boolean}
5947
5972
  */
5948
- validate: function(validator, $field, options) {
5949
- var value = validator.getFieldValue($field, 'imei');
5973
+ validate: function(validator, $field, options, validatorName) {
5974
+ var value = validator.getFieldValue($field, validatorName);
5950
5975
  if (value === '') {
5951
5976
  return true;
5952
5977
  }
@@ -5982,9 +6007,6 @@ if (typeof jQuery === 'undefined') {
5982
6007
  FormValidation.Validator.imo = {
5983
6008
  /**
5984
6009
  * Validate IMO (International Maritime Organization)
5985
- * Examples:
5986
- * - Valid: IMO 8814275, IMO 9176187
5987
- * - Invalid: IMO 8814274
5988
6010
  *
5989
6011
  * @see http://en.wikipedia.org/wiki/IMO_Number
5990
6012
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -5993,8 +6015,8 @@ if (typeof jQuery === 'undefined') {
5993
6015
  * - message: The invalid message
5994
6016
  * @returns {Boolean}
5995
6017
  */
5996
- validate: function(validator, $field, options) {
5997
- var value = validator.getFieldValue($field, 'imo');
6018
+ validate: function(validator, $field, options, validatorName) {
6019
+ var value = validator.getFieldValue($field, validatorName);
5998
6020
  if (value === '') {
5999
6021
  return true;
6000
6022
  }
@@ -6002,15 +6024,10 @@ if (typeof jQuery === 'undefined') {
6002
6024
  if (!/^IMO \d{7}$/i.test(value)) {
6003
6025
  return false;
6004
6026
  }
6005
-
6027
+
6006
6028
  // Grab just the digits
6007
6029
  var sum = 0,
6008
6030
  digits = value.replace(/^.*(\d{7})$/, '$1');
6009
-
6010
- // Go over each char, multiplying by the inverse of it's position
6011
- // IMO 9176187
6012
- // (9 * 7) + (1 * 6) + (7 * 5) + (6 * 4) + (1 * 3) + (8 * 2) = 147
6013
- // Take the last digit of that, that's the check digit (7)
6014
6031
  for (var i = 6; i >= 1; i--) {
6015
6032
  sum += (digits.slice((6 - i), -i) * (i + 1));
6016
6033
  }
@@ -6029,6 +6046,12 @@ if (typeof jQuery === 'undefined') {
6029
6046
  });
6030
6047
 
6031
6048
  FormValidation.Validator.integer = {
6049
+ html5Attributes: {
6050
+ message: 'message',
6051
+ thousandsseparator: 'thousandsSeparator',
6052
+ decimalseparator: 'decimalSeparator'
6053
+ },
6054
+
6032
6055
  enableByHtml5: function($field) {
6033
6056
  return ('number' === $field.attr('type')) && ($field.attr('step') === undefined || $field.attr('step') % 1 === 0);
6034
6057
  },
@@ -6040,18 +6063,47 @@ if (typeof jQuery === 'undefined') {
6040
6063
  * @param {jQuery} $field Field element
6041
6064
  * @param {Object} options Can consist of the following key:
6042
6065
  * - message: The invalid message
6066
+ * - thousandsSeparator: The thousands separator. It's empty by default
6067
+ * - decimalSeparator: The decimal separator. It's '.' by default
6043
6068
  * @returns {Boolean}
6044
6069
  */
6045
- validate: function(validator, $field, options) {
6070
+ validate: function(validator, $field, options, validatorName) {
6046
6071
  if (this.enableByHtml5($field) && $field.get(0).validity && $field.get(0).validity.badInput === true) {
6047
6072
  return false;
6048
6073
  }
6049
6074
 
6050
- var value = validator.getFieldValue($field, 'integer');
6075
+ var value = validator.getFieldValue($field, validatorName);
6051
6076
  if (value === '') {
6052
6077
  return true;
6053
6078
  }
6054
- return /^(?:-?(?:0|[1-9][0-9]*))$/.test(value);
6079
+
6080
+ var decimalSeparator = options.decimalSeparator || '.',
6081
+ thousandsSeparator = options.thousandsSeparator || '';
6082
+ decimalSeparator = (decimalSeparator === '.') ? '\\.' : decimalSeparator;
6083
+ thousandsSeparator = (thousandsSeparator === '.') ? '\\.' : thousandsSeparator;
6084
+
6085
+ var testRegexp = new RegExp('^-?[0-9]{1,3}(' + thousandsSeparator + '[0-9]{3})*(' + decimalSeparator + '[0-9]+)?$'),
6086
+ thousandsReplacer = new RegExp(thousandsSeparator, 'g');
6087
+
6088
+ if (!testRegexp.test(value)) {
6089
+ return false;
6090
+ }
6091
+
6092
+ // Replace thousands separator with blank
6093
+ if (thousandsSeparator) {
6094
+ value = value.replace(thousandsReplacer, '');
6095
+ }
6096
+ // Replace decimal separator with a dot
6097
+ if (decimalSeparator) {
6098
+ value = value.replace(decimalSeparator, '.');
6099
+ }
6100
+
6101
+ if (isNaN(value) || !isFinite(value)) {
6102
+ return false;
6103
+ }
6104
+ // TODO: Use Number.isInteger() if available
6105
+ value = parseFloat(value);
6106
+ return Math.floor(value) === value;
6055
6107
  }
6056
6108
  };
6057
6109
  }(jQuery));
@@ -6084,8 +6136,8 @@ if (typeof jQuery === 'undefined') {
6084
6136
  * - message: The invalid message
6085
6137
  * @returns {Boolean|Object}
6086
6138
  */
6087
- validate: function(validator, $field, options) {
6088
- var value = validator.getFieldValue($field, 'ip');
6139
+ validate: function(validator, $field, options, validatorName) {
6140
+ var value = validator.getFieldValue($field, validatorName);
6089
6141
  if (value === '') {
6090
6142
  return true;
6091
6143
  }
@@ -6135,23 +6187,16 @@ if (typeof jQuery === 'undefined') {
6135
6187
  FormValidation.Validator.isbn = {
6136
6188
  /**
6137
6189
  * Return true if the input value is a valid ISBN 10 or ISBN 13 number
6138
- * Examples:
6139
- * - Valid:
6140
- * ISBN 10: 99921-58-10-7, 9971-5-0210-0, 960-425-059-0, 80-902734-1-6, 85-359-0277-5, 1-84356-028-3, 0-684-84328-5, 0-8044-2957-X, 0-85131-041-9, 0-943396-04-2, 0-9752298-0-X
6141
- * ISBN 13: 978-0-306-40615-7
6142
- * - Invalid:
6143
- * ISBN 10: 99921-58-10-6
6144
- * ISBN 13: 978-0-306-40615-6
6145
6190
  *
6146
6191
  * @see http://en.wikipedia.org/wiki/International_Standard_Book_Number
6147
6192
  * @param {FormValidation.Base} validator The validator plugin instance
6148
6193
  * @param {jQuery} $field Field element
6149
6194
  * @param {Object} [options] Can consist of the following keys:
6150
6195
  * - message: The invalid message
6151
- * @returns {Boolean}
6196
+ * @returns {Boolean|Object}
6152
6197
  */
6153
- validate: function(validator, $field, options) {
6154
- var value = validator.getFieldValue($field, 'isbn');
6198
+ validate: function(validator, $field, options, validatorName) {
6199
+ var value = validator.getFieldValue($field, validatorName);
6155
6200
  if (value === '') {
6156
6201
  return true;
6157
6202
  }
@@ -6194,7 +6239,10 @@ if (typeof jQuery === 'undefined') {
6194
6239
  } else if (checksum === 10) {
6195
6240
  checksum = 'X';
6196
6241
  }
6197
- return (checksum + '' === chars[length - 1]);
6242
+ return {
6243
+ type: type,
6244
+ valid: (checksum + '' === chars[length - 1])
6245
+ };
6198
6246
 
6199
6247
  case 'ISBN13':
6200
6248
  sum = 0;
@@ -6205,7 +6253,10 @@ if (typeof jQuery === 'undefined') {
6205
6253
  if (checksum === 10) {
6206
6254
  checksum = '0';
6207
6255
  }
6208
- return (checksum + '' === chars[length - 1]);
6256
+ return {
6257
+ type: type,
6258
+ valid: (checksum + '' === chars[length - 1])
6259
+ };
6209
6260
 
6210
6261
  default:
6211
6262
  return false;
@@ -6229,9 +6280,6 @@ if (typeof jQuery === 'undefined') {
6229
6280
 
6230
6281
  /**
6231
6282
  * Validate an ISIN (International Securities Identification Number)
6232
- * Examples:
6233
- * - Valid: US0378331005, AU0000XVGZA3, GB0002634946
6234
- * - Invalid: US0378331004, AA0000XVGZA3
6235
6283
  *
6236
6284
  * @see http://en.wikipedia.org/wiki/International_Securities_Identifying_Number
6237
6285
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -6240,8 +6288,8 @@ if (typeof jQuery === 'undefined') {
6240
6288
  * - message: The invalid message
6241
6289
  * @returns {Boolean}
6242
6290
  */
6243
- validate: function(validator, $field, options) {
6244
- var value = validator.getFieldValue($field, 'isin');
6291
+ validate: function(validator, $field, options, validatorName) {
6292
+ var value = validator.getFieldValue($field, validatorName);
6245
6293
  if (value === '') {
6246
6294
  return true;
6247
6295
  }
@@ -6288,19 +6336,16 @@ if (typeof jQuery === 'undefined') {
6288
6336
  FormValidation.Validator.ismn = {
6289
6337
  /**
6290
6338
  * Validate ISMN (International Standard Music Number)
6291
- * Examples:
6292
- * - Valid: M230671187, 979-0-0601-1561-5, 979 0 3452 4680 5, 9790060115615
6293
- * - Invalid: 9790060115614
6294
6339
  *
6295
6340
  * @see http://en.wikipedia.org/wiki/International_Standard_Music_Number
6296
6341
  * @param {FormValidation.Base} validator The validator plugin instance
6297
6342
  * @param {jQuery} $field Field element
6298
6343
  * @param {Object} options Can consist of the following keys:
6299
6344
  * - message: The invalid message
6300
- * @returns {Boolean}
6345
+ * @returns {Boolean|Object}
6301
6346
  */
6302
- validate: function(validator, $field, options) {
6303
- var value = validator.getFieldValue($field, 'ismn');
6347
+ validate: function(validator, $field, options, validatorName) {
6348
+ var value = validator.getFieldValue($field, validatorName);
6304
6349
  if (value === '') {
6305
6350
  return true;
6306
6351
  }
@@ -6335,7 +6380,10 @@ if (typeof jQuery === 'undefined') {
6335
6380
  sum += parseInt(value.charAt(i), 10) * weight[i % 2];
6336
6381
  }
6337
6382
  sum = 10 - sum % 10;
6338
- return (sum + '' === value.charAt(length - 1));
6383
+ return {
6384
+ type: type,
6385
+ valid: (sum + '' === value.charAt(length - 1))
6386
+ };
6339
6387
  }
6340
6388
  };
6341
6389
  }(jQuery));
@@ -6351,9 +6399,6 @@ if (typeof jQuery === 'undefined') {
6351
6399
  FormValidation.Validator.issn = {
6352
6400
  /**
6353
6401
  * Validate ISSN (International Standard Serial Number)
6354
- * Examples:
6355
- * - Valid: 0378-5955, 0024-9319, 0032-1478
6356
- * - Invalid: 0032-147X
6357
6402
  *
6358
6403
  * @see http://en.wikipedia.org/wiki/International_Standard_Serial_Number
6359
6404
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -6362,8 +6407,8 @@ if (typeof jQuery === 'undefined') {
6362
6407
  * - message: The invalid message
6363
6408
  * @returns {Boolean}
6364
6409
  */
6365
- validate: function(validator, $field, options) {
6366
- var value = validator.getFieldValue($field, 'issn');
6410
+ validate: function(validator, $field, options, validatorName) {
6411
+ var value = validator.getFieldValue($field, validatorName);
6367
6412
  if (value === '') {
6368
6413
  return true;
6369
6414
  }
@@ -6434,29 +6479,25 @@ if (typeof jQuery === 'undefined') {
6434
6479
  * - message: The invalid message
6435
6480
  * @returns {Boolean|Object}
6436
6481
  */
6437
- validate: function(validator, $field, options) {
6438
- var value = validator.getFieldValue($field, 'lessThan');
6482
+ validate: function(validator, $field, options, validatorName) {
6483
+ var value = validator.getFieldValue($field, validatorName);
6439
6484
  if (value === '') {
6440
6485
  return true;
6441
6486
  }
6442
-
6487
+
6443
6488
  value = this._format(value);
6444
- if (!$.isNumeric(value)) {
6445
- return false;
6446
- }
6447
6489
 
6448
6490
  var locale = validator.getLocale(),
6449
6491
  compareTo = $.isNumeric(options.value) ? options.value : validator.getDynamicOption($field, options.value),
6450
6492
  compareToValue = this._format(compareTo);
6451
6493
 
6452
- value = parseFloat(value);
6453
6494
  return (options.inclusive === true || options.inclusive === undefined)
6454
6495
  ? {
6455
- valid: value <= compareToValue,
6496
+ valid: $.isNumeric(value) && parseFloat(value) <= compareToValue,
6456
6497
  message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].lessThan['default'], compareTo)
6457
6498
  }
6458
6499
  : {
6459
- valid: value < compareToValue,
6500
+ valid: $.isNumeric(value) && parseFloat(value) < compareToValue,
6460
6501
  message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].lessThan.notInclusive, compareTo)
6461
6502
  };
6462
6503
  },
@@ -6485,8 +6526,8 @@ if (typeof jQuery === 'undefined') {
6485
6526
  * - message: The invalid message
6486
6527
  * @returns {Boolean}
6487
6528
  */
6488
- validate: function(validator, $field, options) {
6489
- var value = validator.getFieldValue($field, 'mac');
6529
+ validate: function(validator, $field, options, validatorName) {
6530
+ var value = validator.getFieldValue($field, validatorName);
6490
6531
  if (value === '') {
6491
6532
  return true;
6492
6533
  }
@@ -6507,9 +6548,6 @@ if (typeof jQuery === 'undefined') {
6507
6548
  FormValidation.Validator.meid = {
6508
6549
  /**
6509
6550
  * Validate MEID (Mobile Equipment Identifier)
6510
- * Examples:
6511
- * - Valid: 293608736500703710, 29360-87365-0070-3710, AF0123450ABCDE, AF-012345-0ABCDE
6512
- * - Invalid: 2936087365007037101
6513
6551
  *
6514
6552
  * @see http://en.wikipedia.org/wiki/Mobile_equipment_identifier
6515
6553
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -6518,8 +6556,8 @@ if (typeof jQuery === 'undefined') {
6518
6556
  * - message: The invalid message
6519
6557
  * @returns {Boolean}
6520
6558
  */
6521
- validate: function(validator, $field, options) {
6522
- var value = validator.getFieldValue($field, 'meid');
6559
+ validate: function(validator, $field, options, validatorName) {
6560
+ var value = validator.getFieldValue($field, validatorName);
6523
6561
  if (value === '') {
6524
6562
  return true;
6525
6563
  }
@@ -6605,7 +6643,7 @@ if (typeof jQuery === 'undefined') {
6605
6643
  * @param {Object} options
6606
6644
  * @returns {Boolean}
6607
6645
  */
6608
- validate: function(validator, $field, options) {
6646
+ validate: function(validator, $field, options, validatorName) {
6609
6647
  var type = $field.attr('type');
6610
6648
  if ('radio' === type || 'checkbox' === type) {
6611
6649
  var ns = validator.getNamespace();
@@ -6619,7 +6657,7 @@ if (typeof jQuery === 'undefined') {
6619
6657
  return true;
6620
6658
  }
6621
6659
 
6622
- var value = validator.getFieldValue($field, 'notEmpty');
6660
+ var value = validator.getFieldValue($field, validatorName);
6623
6661
  return $.trim(value) !== '';
6624
6662
  }
6625
6663
  };
@@ -6636,7 +6674,9 @@ if (typeof jQuery === 'undefined') {
6636
6674
  FormValidation.Validator.numeric = {
6637
6675
  html5Attributes: {
6638
6676
  message: 'message',
6639
- separator: 'separator'
6677
+ separator: 'separator', // deprecated
6678
+ thousandsseparator: 'thousandsSeparator',
6679
+ decimalseparator: 'decimalSeparator'
6640
6680
  },
6641
6681
 
6642
6682
  enableByHtml5: function($field) {
@@ -6650,21 +6690,39 @@ if (typeof jQuery === 'undefined') {
6650
6690
  * @param {jQuery} $field Field element
6651
6691
  * @param {Object} options Consist of key:
6652
6692
  * - message: The invalid message
6653
- * - separator: The decimal separator. Can be "." (default), ","
6693
+ * - thousandsSeparator: The thousands separator. It's empty by default
6694
+ * - separator, decimalSeparator: The decimal separator. It's '.' by default
6695
+ * The separator option is deprecated and should be replaced with decimalSeparator
6654
6696
  * @returns {Boolean}
6655
6697
  */
6656
- validate: function(validator, $field, options) {
6698
+ validate: function(validator, $field, options, validatorName) {
6657
6699
  if (this.enableByHtml5($field) && $field.get(0).validity && $field.get(0).validity.badInput === true) {
6658
6700
  return false;
6659
6701
  }
6660
6702
 
6661
- var value = validator.getFieldValue($field, 'numeric');
6703
+ var value = validator.getFieldValue($field, validatorName);
6662
6704
  if (value === '') {
6663
6705
  return true;
6664
6706
  }
6665
- var separator = options.separator || '.';
6666
- if (separator !== '.') {
6667
- value = value.replace(separator, '.');
6707
+ var decimalSeparator = options.separator || options.decimalSeparator || '.',
6708
+ thousandsSeparator = options.thousandsSeparator || '';
6709
+ decimalSeparator = (decimalSeparator === '.') ? '\\.' : decimalSeparator;
6710
+ thousandsSeparator = (thousandsSeparator === '.') ? '\\.' : thousandsSeparator;
6711
+
6712
+ var testRegexp = new RegExp('^-?[0-9]{1,3}(' + thousandsSeparator + '[0-9]{3})*(' + decimalSeparator + '[0-9]+)?$'),
6713
+ thousandsReplacer = new RegExp(thousandsSeparator, 'g');
6714
+
6715
+ if (!testRegexp.test(value)) {
6716
+ return false;
6717
+ }
6718
+
6719
+ // Replace thousands separator with blank
6720
+ if (thousandsSeparator) {
6721
+ value = value.replace(thousandsReplacer, '');
6722
+ }
6723
+ // Replace decimal separator with a dot
6724
+ if (decimalSeparator) {
6725
+ value = value.replace(decimalSeparator, '.');
6668
6726
  }
6669
6727
 
6670
6728
  return !isNaN(parseFloat(value)) && isFinite(value);
@@ -6728,8 +6786,8 @@ if (typeof jQuery === 'undefined') {
6728
6786
  *
6729
6787
  * @returns {Boolean|Object}
6730
6788
  */
6731
- validate: function(validator, $field, options) {
6732
- var value = validator.getFieldValue($field, 'phone');
6789
+ validate: function(validator, $field, options, validatorName) {
6790
+ var value = validator.getFieldValue($field, validatorName);
6733
6791
  if (value === '') {
6734
6792
  return true;
6735
6793
  }
@@ -6752,7 +6810,7 @@ if (typeof jQuery === 'undefined') {
6752
6810
  value = $.trim(value);
6753
6811
  isValid = (/^(((\+|00)?971[\s\.-]?(\(0\)[\s\.-]?)?|0)(\(5(0|2|5|6)\)|5(0|2|5|6)|2|3|4|6|7|9)|60)([\s\.-]?[0-9]){7}$/).test(value);
6754
6812
  break;
6755
-
6813
+
6756
6814
  case 'BG':
6757
6815
  // https://regex101.com/r/yE6vN4/1
6758
6816
  // See http://en.wikipedia.org/wiki/Telephone_numbers_in_Bulgaria
@@ -6817,7 +6875,7 @@ if (typeof jQuery === 'undefined') {
6817
6875
  value = $.trim(value);
6818
6876
  isValid = (/^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|0)(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}|\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4}|\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3})|\d{5}\)?[\s-]?\d{4,5}|8(?:00[\s-]?11[\s-]?11|45[\s-]?46[\s-]?4\d))(?:(?:[\s-]?(?:x|ext\.?\s?|\#)\d+)?)$/).test(value);
6819
6877
  break;
6820
-
6878
+
6821
6879
  case 'IN':
6822
6880
  // http://stackoverflow.com/questions/18351553/regular-expression-validation-for-indian-phone-number-and-mobile-number
6823
6881
  // http://regex101.com/r/qL6eZ5/1
@@ -6825,21 +6883,21 @@ if (typeof jQuery === 'undefined') {
6825
6883
  value = $.trim(value);
6826
6884
  isValid = (/((\+?)((0[ -]+)*|(91 )*)(\d{12}|\d{10}))|\d{5}([- ]*)\d{6}/).test(value);
6827
6885
  break;
6828
-
6886
+
6829
6887
  case 'MA':
6830
6888
  // http://en.wikipedia.org/wiki/Telephone_numbers_in_Morocco
6831
6889
  // http://regexr.com/399n8
6832
6890
  value = $.trim(value);
6833
6891
  isValid = (/^(?:(?:(?:\+|00)212[\s]?(?:[\s]?\(0\)[\s]?)?)|0){1}(?:5[\s.-]?[2-3]|6[\s.-]?[13-9]){1}[0-9]{1}(?:[\s.-]?\d{2}){3}$/).test(value);
6834
6892
  break;
6835
-
6893
+
6836
6894
  case 'NL':
6837
6895
  // http://en.wikipedia.org/wiki/Telephone_numbers_in_the_Netherlands
6838
6896
  // http://regexr.com/3aevr
6839
6897
  value = $.trim(value);
6840
6898
  isValid = (/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9])((\s|\s?-\s?)?[0-9])((\s|\s?-\s?)?[0-9])\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]$/gm).test(value);
6841
6899
  break;
6842
-
6900
+
6843
6901
  case 'PK':
6844
6902
  // http://regex101.com/r/yH8aV9/2
6845
6903
  value = $.trim(value);
@@ -6872,7 +6930,7 @@ if (typeof jQuery === 'undefined') {
6872
6930
  value = $.trim(value);
6873
6931
  isValid = (/^0(?:2(?:12|4[0-9]|5[1-9]|6[0-9]|7[0-8]|8[1-35-8]|9[1-5]|3[45789])|4(?:1[246]|2[46]))\d{7}$/).test(value);
6874
6932
  break;
6875
-
6933
+
6876
6934
  case 'US':
6877
6935
  /* falls through */
6878
6936
  default:
@@ -6891,6 +6949,74 @@ if (typeof jQuery === 'undefined') {
6891
6949
  }
6892
6950
  };
6893
6951
  }(jQuery));
6952
+ ;(function($) {
6953
+ FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
6954
+ 'en_US': {
6955
+ promise: {
6956
+ 'default': 'Please enter a valid value'
6957
+ }
6958
+ }
6959
+ });
6960
+
6961
+ FormValidation.Validator.promise = {
6962
+ html5Attributes: {
6963
+ message: 'message',
6964
+ promise: 'promise'
6965
+ },
6966
+
6967
+ /**
6968
+ * Return result from a jQuery's Deferred object
6969
+ *
6970
+ * @param {FormValidation.Base} validator The validator plugin instance
6971
+ * @param {jQuery} $field Field element
6972
+ * @param {Object} options Can consist of the following keys:
6973
+ * - promise: The method that passes parameters:
6974
+ * promise: function(fieldValue, validator, $field) {
6975
+ * // fieldValue is the value of field
6976
+ * // validator is instance of FormValidation.Base
6977
+ * // $field is the field element
6978
+ *
6979
+ * var dfd = new $.Deferred();
6980
+ *
6981
+ * // Do something ...
6982
+ *
6983
+ * // Resolve when particular task is done
6984
+ * dfd.resolve({
6985
+ * valid: true or false, // Required
6986
+ * message: 'Other message', // Optional
6987
+ * key: value // You can attach more data to reuse later
6988
+ * });
6989
+ *
6990
+ * // You can reject if there's error
6991
+ * dfd.reject({
6992
+ * message: 'Other message', // Optional
6993
+ * key: value // You can attach more data to reuse later
6994
+ * });
6995
+ *
6996
+ * return dfd.promise();
6997
+ * }
6998
+ * - message: The invalid message
6999
+ * @returns {Deferred}
7000
+ */
7001
+ validate: function(validator, $field, options, validatorName) {
7002
+ var value = validator.getFieldValue($field, validatorName),
7003
+ dfd = new $.Deferred(),
7004
+ promise = FormValidation.Helper.call(options.promise, [value, validator, $field]);
7005
+
7006
+ promise
7007
+ .done(function(result) {
7008
+ dfd.resolve($field, validatorName, result);
7009
+ })
7010
+ .fail(function(result) {
7011
+ result = result || {};
7012
+ result.valid = false;
7013
+ dfd.resolve($field, validatorName, result);
7014
+ });
7015
+
7016
+ return dfd;
7017
+ }
7018
+ };
7019
+ }(jQuery));
6894
7020
  ;(function($) {
6895
7021
  FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, {
6896
7022
  'en_US': {
@@ -6926,8 +7052,8 @@ if (typeof jQuery === 'undefined') {
6926
7052
  * - regexp: The regular expression you need to check
6927
7053
  * @returns {Boolean}
6928
7054
  */
6929
- validate: function(validator, $field, options) {
6930
- var value = validator.getFieldValue($field, 'regexp');
7055
+ validate: function(validator, $field, options, validatorName) {
7056
+ var value = validator.getFieldValue($field, validatorName);
6931
7057
  if (value === '') {
6932
7058
  return true;
6933
7059
  }
@@ -6962,12 +7088,12 @@ if (typeof jQuery === 'undefined') {
6962
7088
  /**
6963
7089
  * Destroy the timer when destroying the FormValidation (using validator.destroy() method)
6964
7090
  */
6965
- destroy: function(validator, $field, options) {
7091
+ destroy: function(validator, $field, options, validatorName) {
6966
7092
  var ns = validator.getNamespace(),
6967
- timer = $field.data(ns + '.remote.timer');
7093
+ timer = $field.data(ns + '.' + validatorName + '.timer');
6968
7094
  if (timer) {
6969
7095
  clearTimeout(timer);
6970
- $field.removeData(ns + '.remote.timer');
7096
+ $field.removeData(ns + '.' + validatorName + '.timer');
6971
7097
  }
6972
7098
  },
6973
7099
 
@@ -6994,12 +7120,12 @@ if (typeof jQuery === 'undefined') {
6994
7120
  * This is useful when connecting to external remote server or APIs provided by 3rd parties
6995
7121
  * @returns {Deferred}
6996
7122
  */
6997
- validate: function(validator, $field, options) {
7123
+ validate: function(validator, $field, options, validatorName) {
6998
7124
  var ns = validator.getNamespace(),
6999
- value = validator.getFieldValue($field, 'remote'),
7125
+ value = validator.getFieldValue($field, validatorName),
7000
7126
  dfd = new $.Deferred();
7001
7127
  if (value === '') {
7002
- dfd.resolve($field, 'remote', { valid: true });
7128
+ dfd.resolve($field, validatorName, { valid: true });
7003
7129
  return dfd;
7004
7130
  }
7005
7131
  var name = $field.attr('data-' + ns + '-field'),
@@ -7009,7 +7135,7 @@ if (typeof jQuery === 'undefined') {
7009
7135
 
7010
7136
  // Support dynamic data
7011
7137
  if ('function' === typeof data) {
7012
- data = data.call(this, validator);
7138
+ data = data.call(this, validator, $field, value);
7013
7139
  }
7014
7140
 
7015
7141
  // Parse string data from HTML5 attribute
@@ -7019,7 +7145,7 @@ if (typeof jQuery === 'undefined') {
7019
7145
 
7020
7146
  // Support dynamic url
7021
7147
  if ('function' === typeof url) {
7022
- url = url.call(this, validator);
7148
+ url = url.call(this, validator, $field, value);
7023
7149
  }
7024
7150
 
7025
7151
  data[options.name || name] = value;
@@ -7043,10 +7169,10 @@ if (typeof jQuery === 'undefined') {
7043
7169
  response.valid = (response[validKey] === true || response[validKey] === 'true')
7044
7170
  ? true
7045
7171
  : (response[validKey] === false || response[validKey] === 'false' ? false : null);
7046
- dfd.resolve($field, 'remote', response);
7172
+ dfd.resolve($field, validatorName, response);
7047
7173
  })
7048
7174
  .error(function(response) {
7049
- dfd.resolve($field, 'remote', {
7175
+ dfd.resolve($field, validatorName, {
7050
7176
  valid: false
7051
7177
  });
7052
7178
  });
@@ -7057,15 +7183,15 @@ if (typeof jQuery === 'undefined') {
7057
7183
 
7058
7184
  return dfd;
7059
7185
  }
7060
-
7186
+
7061
7187
  if (options.delay) {
7062
7188
  // Since the form might have multiple fields with the same name
7063
7189
  // I have to attach the timer to the field element
7064
- if ($field.data(ns + '.remote.timer')) {
7065
- clearTimeout($field.data(ns + '.remote.timer'));
7190
+ if ($field.data(ns + '.' + validatorName + '.timer')) {
7191
+ clearTimeout($field.data(ns + '.' + validatorName + '.timer'));
7066
7192
  }
7067
7193
 
7068
- $field.data(ns + '.remote.timer', setTimeout(runCallback, options.delay));
7194
+ $field.data(ns + '.' + validatorName + '.timer', setTimeout(runCallback, options.delay));
7069
7195
  return dfd;
7070
7196
  } else {
7071
7197
  return runCallback();
@@ -7085,8 +7211,6 @@ if (typeof jQuery === 'undefined') {
7085
7211
  FormValidation.Validator.rtn = {
7086
7212
  /**
7087
7213
  * Validate a RTN (Routing transit number)
7088
- * Examples:
7089
- * - Valid: 021200025, 789456124
7090
7214
  *
7091
7215
  * @see http://en.wikipedia.org/wiki/Routing_transit_number
7092
7216
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -7095,8 +7219,8 @@ if (typeof jQuery === 'undefined') {
7095
7219
  * - message: The invalid message
7096
7220
  * @returns {Boolean}
7097
7221
  */
7098
- validate: function(validator, $field, options) {
7099
- var value = validator.getFieldValue($field, 'rtn');
7222
+ validate: function(validator, $field, options, validatorName) {
7223
+ var value = validator.getFieldValue($field, validatorName);
7100
7224
  if (value === '') {
7101
7225
  return true;
7102
7226
  }
@@ -7127,8 +7251,6 @@ if (typeof jQuery === 'undefined') {
7127
7251
  FormValidation.Validator.sedol = {
7128
7252
  /**
7129
7253
  * Validate a SEDOL (Stock Exchange Daily Official List)
7130
- * Examples:
7131
- * - Valid: 0263494, B0WNLY7
7132
7254
  *
7133
7255
  * @see http://en.wikipedia.org/wiki/SEDOL
7134
7256
  * @param {FormValidation.Base} validator The validator plugin instance
@@ -7137,8 +7259,8 @@ if (typeof jQuery === 'undefined') {
7137
7259
  * - message: The invalid message
7138
7260
  * @returns {Boolean}
7139
7261
  */
7140
- validate: function(validator, $field, options) {
7141
- var value = validator.getFieldValue($field, 'sedol');
7262
+ validate: function(validator, $field, options, validatorName) {
7263
+ var value = validator.getFieldValue($field, validatorName);
7142
7264
  if (value === '') {
7143
7265
  return true;
7144
7266
  }
@@ -7178,8 +7300,8 @@ if (typeof jQuery === 'undefined') {
7178
7300
  * - message: The invalid message
7179
7301
  * @returns {Boolean}
7180
7302
  */
7181
- validate: function(validator, $field, options) {
7182
- var value = validator.getFieldValue($field, 'siren');
7303
+ validate: function(validator, $field, options, validatorName) {
7304
+ var value = validator.getFieldValue($field, validatorName);
7183
7305
  if (value === '') {
7184
7306
  return true;
7185
7307
  }
@@ -7210,8 +7332,8 @@ if (typeof jQuery === 'undefined') {
7210
7332
  * - message: The invalid message
7211
7333
  * @returns {Boolean}
7212
7334
  */
7213
- validate: function(validator, $field, options) {
7214
- var value = validator.getFieldValue($field, 'siret');
7335
+ validate: function(validator, $field, options, validatorName) {
7336
+ var value = validator.getFieldValue($field, validatorName);
7215
7337
  if (value === '') {
7216
7338
  return true;
7217
7339
  }
@@ -7260,8 +7382,8 @@ if (typeof jQuery === 'undefined') {
7260
7382
  * - message: The invalid message
7261
7383
  * @returns {Boolean|Object}
7262
7384
  */
7263
- validate: function(validator, $field, options) {
7264
- var value = validator.getFieldValue($field, 'step');
7385
+ validate: function(validator, $field, options, validatorName) {
7386
+ var value = validator.getFieldValue($field, validatorName);
7265
7387
  if (value === '') {
7266
7388
  return true;
7267
7389
  }
@@ -7328,8 +7450,8 @@ if (typeof jQuery === 'undefined') {
7328
7450
  * - case: Can be 'lower' (default) or 'upper'
7329
7451
  * @returns {Object}
7330
7452
  */
7331
- validate: function(validator, $field, options) {
7332
- var value = validator.getFieldValue($field, 'stringCase');
7453
+ validate: function(validator, $field, options, validatorName) {
7454
+ var value = validator.getFieldValue($field, validatorName);
7333
7455
  if (value === '') {
7334
7456
  return true;
7335
7457
  }
@@ -7398,8 +7520,8 @@ if (typeof jQuery === 'undefined') {
7398
7520
  * - utf8bytes: Evaluate string length in UTF-8 bytes, default to false
7399
7521
  * @returns {Object}
7400
7522
  */
7401
- validate: function(validator, $field, options) {
7402
- var value = validator.getFieldValue($field, 'stringLength');
7523
+ validate: function(validator, $field, options, validatorName) {
7524
+ var value = validator.getFieldValue($field, validatorName);
7403
7525
  if (options.trim === true || options.trim === 'true') {
7404
7526
  value = $.trim(value);
7405
7527
  }
@@ -7441,11 +7563,11 @@ if (typeof jQuery === 'undefined') {
7441
7563
  break;
7442
7564
 
7443
7565
  case (!!min):
7444
- message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.more, parseInt(min, 10));
7566
+ message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.more, parseInt(min, 10) - 1);
7445
7567
  break;
7446
7568
 
7447
7569
  case (!!max):
7448
- message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.less, parseInt(max, 10));
7570
+ message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].stringLength.less, parseInt(max, 10) + 1);
7449
7571
  break;
7450
7572
 
7451
7573
  default:
@@ -7492,8 +7614,8 @@ if (typeof jQuery === 'undefined') {
7492
7614
  * - protocol: The protocols, separated by a comma. Default to "http, https, ftp"
7493
7615
  * @returns {Boolean}
7494
7616
  */
7495
- validate: function(validator, $field, options) {
7496
- var value = validator.getFieldValue($field, 'uri');
7617
+ validate: function(validator, $field, options, validatorName) {
7618
+ var value = validator.getFieldValue($field, validatorName);
7497
7619
  if (value === '') {
7498
7620
  return true;
7499
7621
  }
@@ -7606,8 +7728,8 @@ if (typeof jQuery === 'undefined') {
7606
7728
  * - version: Can be 3, 4, 5, null
7607
7729
  * @returns {Boolean|Object}
7608
7730
  */
7609
- validate: function(validator, $field, options) {
7610
- var value = validator.getFieldValue($field, 'uuid');
7731
+ validate: function(validator, $field, options, validatorName) {
7732
+ var value = validator.getFieldValue($field, validatorName);
7611
7733
  if (value === '') {
7612
7734
  return true;
7613
7735
  }
@@ -7704,10 +7826,10 @@ if (typeof jQuery === 'undefined') {
7704
7826
  * - Name of field which its value defines the country code
7705
7827
  * - Name of callback function that returns the country code
7706
7828
  * - A callback function that returns the country code
7707
- * @returns {Boolean|Object}
7829
+ * @returns {Object}
7708
7830
  */
7709
- validate: function(validator, $field, options) {
7710
- var value = validator.getFieldValue($field, 'vat');
7831
+ validate: function(validator, $field, options, validatorName) {
7832
+ var value = validator.getFieldValue($field, validatorName);
7711
7833
  if (value === '') {
7712
7834
  return true;
7713
7835
  }
@@ -7725,22 +7847,18 @@ if (typeof jQuery === 'undefined') {
7725
7847
  return true;
7726
7848
  }
7727
7849
 
7728
- var method = ['_', country.toLowerCase()].join('');
7729
- return this[method](value)
7730
- ? true
7731
- : {
7732
- valid: false,
7733
- message: FormValidation.Helper.format(options.message || FormValidation.I18n[locale].vat.country, FormValidation.I18n[locale].vat.countries[country.toUpperCase()])
7734
- };
7850
+ var method = ['_', country.toLowerCase()].join(''),
7851
+ result = this[method](value);
7852
+ result = (result === true || result === false) ? { valid: result } : result;
7853
+ result.message = FormValidation.Helper.format(options.message || FormValidation.I18n[locale].vat.country, FormValidation.I18n[locale].vat.countries[country.toUpperCase()]);
7854
+
7855
+ return result;
7735
7856
  },
7736
7857
 
7737
7858
  // VAT validators
7738
7859
 
7739
7860
  /**
7740
7861
  * Validate Austrian VAT number
7741
- * Example:
7742
- * - Valid: ATU13585627
7743
- * - Invalid: ATU13585626
7744
7862
  *
7745
7863
  * @param {String} value VAT number
7746
7864
  * @returns {Boolean}
@@ -7775,9 +7893,6 @@ if (typeof jQuery === 'undefined') {
7775
7893
 
7776
7894
  /**
7777
7895
  * Validate Belgian VAT number
7778
- * Example:
7779
- * - Valid: BE0428759497
7780
- * - Invalid: BE431150351
7781
7896
  *
7782
7897
  * @param {String} value VAT number
7783
7898
  * @returns {Boolean}
@@ -7803,12 +7918,6 @@ if (typeof jQuery === 'undefined') {
7803
7918
 
7804
7919
  /**
7805
7920
  * Validate Bulgarian VAT number
7806
- * Example:
7807
- * - Valid: BG175074752,
7808
- * BG7523169263, BG8032056031,
7809
- * BG7542011030,
7810
- * BG7111042925
7811
- * - Invalid: BG175074753, BG7552A10004, BG7111042922
7812
7921
  *
7813
7922
  * @param {String} value VAT number
7814
7923
  * @returns {Boolean}
@@ -7897,7 +8006,7 @@ if (typeof jQuery === 'undefined') {
7897
8006
 
7898
8007
  return false;
7899
8008
  },
7900
-
8009
+
7901
8010
  /**
7902
8011
  * Validate Brazilian VAT number (CNPJ)
7903
8012
  *
@@ -7990,9 +8099,6 @@ if (typeof jQuery === 'undefined') {
7990
8099
 
7991
8100
  /**
7992
8101
  * Validate Cypriot VAT number
7993
- * Examples:
7994
- * - Valid: CY10259033P
7995
- * - Invalid: CY10259033Z
7996
8102
  *
7997
8103
  * @param {String} value VAT number
7998
8104
  * @returns {Boolean}
@@ -8030,14 +8136,6 @@ if (typeof jQuery === 'undefined') {
8030
8136
 
8031
8137
  /**
8032
8138
  * Validate Czech Republic VAT number
8033
- * Can be:
8034
- * i) Legal entities (8 digit numbers)
8035
- * ii) Individuals with a RC (the 9 or 10 digit Czech birth number)
8036
- * iii) Individuals without a RC (9 digit numbers beginning with 6)
8037
- *
8038
- * Examples:
8039
- * - Valid: i) CZ25123891; ii) CZ7103192745, CZ991231123; iii) CZ640903926
8040
- * - Invalid: i) CZ25123890; ii) CZ1103492745, CZ590312123
8041
8139
  *
8042
8140
  * @param {String} value VAT number
8043
8141
  * @returns {Boolean}
@@ -8123,9 +8221,6 @@ if (typeof jQuery === 'undefined') {
8123
8221
 
8124
8222
  /**
8125
8223
  * Validate German VAT number
8126
- * Examples:
8127
- * - Valid: DE136695976
8128
- * - Invalid: DE136695978
8129
8224
  *
8130
8225
  * @param {String} value VAT number
8131
8226
  * @returns {Boolean}
@@ -8143,9 +8238,6 @@ if (typeof jQuery === 'undefined') {
8143
8238
 
8144
8239
  /**
8145
8240
  * Validate Danish VAT number
8146
- * Example:
8147
- * - Valid: DK13585628
8148
- * - Invalid: DK13585627
8149
8241
  *
8150
8242
  * @param {String} value VAT number
8151
8243
  * @returns {Boolean}
@@ -8169,9 +8261,6 @@ if (typeof jQuery === 'undefined') {
8169
8261
 
8170
8262
  /**
8171
8263
  * Validate Estonian VAT number
8172
- * Examples:
8173
- * - Valid: EE100931558, EE100594102
8174
- * - Invalid: EE100594103
8175
8264
  *
8176
8265
  * @param {String} value VAT number
8177
8266
  * @returns {Boolean}
@@ -8200,12 +8289,8 @@ if (typeof jQuery === 'undefined') {
8200
8289
  * ii) NIE (Número de Identificación de Extranjeros), for foreigners
8201
8290
  * iii) CIF (Certificado de Identificación Fiscal), for legal entities and others
8202
8291
  *
8203
- * Examples:
8204
- * - Valid: i) ES54362315K; ii) ESX2482300W, ESX5253868R; iii) ESM1234567L, ESJ99216582, ESB58378431, ESB64717838
8205
- * - Invalid: i) ES54362315Z; ii) ESX2482300A; iii) ESJ99216583
8206
- *
8207
8292
  * @param {String} value VAT number
8208
- * @returns {Boolean}
8293
+ * @returns {Boolean|Object}
8209
8294
  */
8210
8295
  _es: function(value) {
8211
8296
  if (/^ES[0-9A-Z][0-9]{7}[0-9A-Z]$/.test(value)) {
@@ -8259,19 +8344,25 @@ if (typeof jQuery === 'undefined') {
8259
8344
 
8260
8345
  var first = value.charAt(0);
8261
8346
  if (/^[0-9]$/.test(first)) {
8262
- return dni(value);
8347
+ return {
8348
+ valid: dni(value),
8349
+ type: 'DNI'
8350
+ };
8263
8351
  } else if (/^[XYZ]$/.test(first)) {
8264
- return nie(value);
8352
+ return {
8353
+ valid: nie(value),
8354
+ type: 'NIE'
8355
+ };
8265
8356
  } else {
8266
- return cif(value);
8357
+ return {
8358
+ valid: cif(value),
8359
+ type: 'CIF'
8360
+ };
8267
8361
  }
8268
8362
  },
8269
8363
 
8270
8364
  /**
8271
8365
  * Validate Finnish VAT number
8272
- * Examples:
8273
- * - Valid: FI20774740
8274
- * - Invalid: FI20774741
8275
8366
  *
8276
8367
  * @param {String} value VAT number
8277
8368
  * @returns {Boolean}
@@ -8297,10 +8388,6 @@ if (typeof jQuery === 'undefined') {
8297
8388
  * Validate French VAT number (TVA - taxe sur la valeur ajoutée)
8298
8389
  * It's constructed by a SIREN number, prefixed by two characters.
8299
8390
  *
8300
- * Examples:
8301
- * - Valid: FR40303265045, FR23334175221, FRK7399859412, FR4Z123456782
8302
- * - Invalid: FR84323140391
8303
- *
8304
8391
  * @param {String} value VAT number
8305
8392
  * @returns {Boolean}
8306
8393
  */
@@ -8335,9 +8422,6 @@ if (typeof jQuery === 'undefined') {
8335
8422
 
8336
8423
  /**
8337
8424
  * Validate United Kingdom VAT number
8338
- * Example:
8339
- * - Valid: GB980780684
8340
- * - Invalid: GB802311781
8341
8425
  *
8342
8426
  * @param {String} value VAT number
8343
8427
  * @returns {Boolean}
@@ -8392,9 +8476,6 @@ if (typeof jQuery === 'undefined') {
8392
8476
 
8393
8477
  /**
8394
8478
  * Validate Greek VAT number
8395
- * Examples:
8396
- * - Valid: GR023456780, EL094259216
8397
- * - Invalid: EL123456781
8398
8479
  *
8399
8480
  * @param {String} value VAT number
8400
8481
  * @returns {Boolean}
@@ -8428,9 +8509,6 @@ if (typeof jQuery === 'undefined') {
8428
8509
 
8429
8510
  /**
8430
8511
  * Validate Hungarian VAT number
8431
- * Examples:
8432
- * - Valid: HU12892312
8433
- * - Invalid: HU12892313
8434
8512
  *
8435
8513
  * @param {String} value VAT number
8436
8514
  * @returns {Boolean}
@@ -8455,9 +8533,6 @@ if (typeof jQuery === 'undefined') {
8455
8533
 
8456
8534
  /**
8457
8535
  * Validate Croatian VAT number
8458
- * Examples:
8459
- * - Valid: HR33392005961
8460
- * - Invalid: HR33392005962
8461
8536
  *
8462
8537
  * @param {String} value VAT number
8463
8538
  * @returns {Boolean}
@@ -8475,9 +8550,6 @@ if (typeof jQuery === 'undefined') {
8475
8550
 
8476
8551
  /**
8477
8552
  * Validate Irish VAT number
8478
- * Examples:
8479
- * - Valid: IE6433435F, IE6433435OA, IE8D79739I
8480
- * - Invalid: IE8D79738J
8481
8553
  *
8482
8554
  * @param {String} value VAT number
8483
8555
  * @returns {Boolean}
@@ -8517,9 +8589,6 @@ if (typeof jQuery === 'undefined') {
8517
8589
 
8518
8590
  /**
8519
8591
  * Validate Icelandic VAT (VSK) number
8520
- * Examples:
8521
- * - Valid: 12345, 123456
8522
- * - Invalid: 1234567
8523
8592
  *
8524
8593
  * @params {String} value VAT number
8525
8594
  * @returns {Boolean}
@@ -8537,10 +8606,6 @@ if (typeof jQuery === 'undefined') {
8537
8606
  * - Next 3 are the province of residence
8538
8607
  * - The last one is a check digit
8539
8608
  *
8540
- * Examples:
8541
- * - Valid: IT00743110157
8542
- * - Invalid: IT00743110158
8543
- *
8544
8609
  * @param {String} value VAT number
8545
8610
  * @returns {Boolean}
8546
8611
  */
@@ -8570,10 +8635,6 @@ if (typeof jQuery === 'undefined') {
8570
8635
  * - 9 digits, for legal entities
8571
8636
  * - 12 digits, for temporarily registered taxpayers
8572
8637
  *
8573
- * Examples:
8574
- * - Valid: LT119511515, LT100001919017, LT100004801610
8575
- * - Invalid: LT100001919018
8576
- *
8577
8638
  * @param {String} value VAT number
8578
8639
  * @returns {Boolean}
8579
8640
  */
@@ -8604,9 +8665,6 @@ if (typeof jQuery === 'undefined') {
8604
8665
 
8605
8666
  /**
8606
8667
  * Validate Luxembourg VAT number
8607
- * Examples:
8608
- * - Valid: LU15027442
8609
- * - Invalid: LU15027443
8610
8668
  *
8611
8669
  * @param {String} value VAT number
8612
8670
  * @returns {Boolean}
@@ -8624,9 +8682,6 @@ if (typeof jQuery === 'undefined') {
8624
8682
 
8625
8683
  /**
8626
8684
  * Validate Latvian VAT number
8627
- * Examples:
8628
- * - Valid: LV40003521600, LV16117519997
8629
- * - Invalid: LV40003521601, LV16137519997
8630
8685
  *
8631
8686
  * @param {String} value VAT number
8632
8687
  * @returns {Boolean}
@@ -8677,9 +8732,6 @@ if (typeof jQuery === 'undefined') {
8677
8732
 
8678
8733
  /**
8679
8734
  * Validate Maltese VAT number
8680
- * Examples:
8681
- * - Valid: MT11679112
8682
- * - Invalid: MT11679113
8683
8735
  *
8684
8736
  * @param {String} value VAT number
8685
8737
  * @returns {Boolean}
@@ -8704,9 +8756,6 @@ if (typeof jQuery === 'undefined') {
8704
8756
 
8705
8757
  /**
8706
8758
  * Validate Dutch VAT number
8707
- * Examples:
8708
- * - Valid: NL004495445B01
8709
- * - Invalid: NL123456789B90
8710
8759
  *
8711
8760
  * @param {String} value VAT number
8712
8761
  * @returns {Boolean}
@@ -8762,9 +8811,6 @@ if (typeof jQuery === 'undefined') {
8762
8811
 
8763
8812
  /**
8764
8813
  * Validate Polish VAT number
8765
- * Examples:
8766
- * - Valid: PL8567346215
8767
- * - Invalid: PL8567346216
8768
8814
  *
8769
8815
  * @param {String} value VAT number
8770
8816
  * @returns {Boolean}
@@ -8789,9 +8835,6 @@ if (typeof jQuery === 'undefined') {
8789
8835
 
8790
8836
  /**
8791
8837
  * Validate Portuguese VAT number
8792
- * Examples:
8793
- * - Valid: PT501964843
8794
- * - Invalid: PT501964842
8795
8838
  *
8796
8839
  * @param {String} value VAT number
8797
8840
  * @returns {Boolean}
@@ -8819,9 +8862,6 @@ if (typeof jQuery === 'undefined') {
8819
8862
 
8820
8863
  /**
8821
8864
  * Validate Romanian VAT number
8822
- * Examples:
8823
- * - Valid: RO18547290
8824
- * - Invalid: RO18547291
8825
8865
  *
8826
8866
  * @param {String} value VAT number
8827
8867
  * @returns {Boolean}
@@ -8926,9 +8966,6 @@ if (typeof jQuery === 'undefined') {
8926
8966
 
8927
8967
  /**
8928
8968
  * Validate Swedish VAT number
8929
- * Examples:
8930
- * - Valid: SE123456789701
8931
- * - Invalid: SE123456789101
8932
8969
  *
8933
8970
  * @param {String} value VAT number
8934
8971
  * @returns {Boolean}
@@ -8947,10 +8984,6 @@ if (typeof jQuery === 'undefined') {
8947
8984
 
8948
8985
  /**
8949
8986
  * Validate Slovenian VAT number
8950
- * Examples:
8951
- * - Valid: SI50223054
8952
- * - Invalid: SI50223055
8953
- * - Invalid: SI09999990
8954
8987
  *
8955
8988
  * @param {String} value VAT number
8956
8989
  * @returns {Boolean}
@@ -8980,9 +9013,6 @@ if (typeof jQuery === 'undefined') {
8980
9013
 
8981
9014
  /**
8982
9015
  * Validate Slovak VAT number
8983
- * Examples:
8984
- * - Valid: SK2022749619
8985
- * - Invalid: SK2022749618
8986
9016
  *
8987
9017
  * @param {String} value VAT number
8988
9018
  * @returns {Boolean}
@@ -9000,9 +9030,6 @@ if (typeof jQuery === 'undefined') {
9000
9030
 
9001
9031
  /**
9002
9032
  * Validate Venezuelan VAT number (RIF)
9003
- * Examples:
9004
- * - Valid: VEJ309272292, VEV242818101, VEJ000126518, VEJ000458324, J309272292, V242818101, J000126518, J000458324
9005
- * - Invalid: VEJ309272293, VEV242818100, J000126519, J000458323
9006
9033
  *
9007
9034
  * @param {String} value VAT number
9008
9035
  * @returns {Boolean}
@@ -9038,9 +9065,6 @@ if (typeof jQuery === 'undefined') {
9038
9065
 
9039
9066
  /**
9040
9067
  * Validate South African VAT number
9041
- * Examples:
9042
- * - Valid: 4012345678
9043
- * - Invalid: 40123456789, 3012345678
9044
9068
  *
9045
9069
  * @params {String} value VAT number
9046
9070
  * @returns {Boolean}
@@ -9073,8 +9097,8 @@ if (typeof jQuery === 'undefined') {
9073
9097
  * - message: The invalid message
9074
9098
  * @returns {Boolean}
9075
9099
  */
9076
- validate: function(validator, $field, options) {
9077
- var value = validator.getFieldValue($field, 'vin');
9100
+ validate: function(validator, $field, options, validatorName) {
9101
+ var value = validator.getFieldValue($field, validatorName);
9078
9102
  if (value === '') {
9079
9103
  return true;
9080
9104
  }
@@ -9168,14 +9192,14 @@ if (typeof jQuery === 'undefined') {
9168
9192
  *
9169
9193
  * callback: function(value, validator, $field) {
9170
9194
  * // value is the value of field
9171
- * // validator is the BootstrapValidator instance
9195
+ * // validator is the FormValidation.Base instance
9172
9196
  * // $field is jQuery element representing the field
9173
9197
  * }
9174
9198
  *
9175
9199
  * @returns {Boolean|Object}
9176
9200
  */
9177
- validate: function(validator, $field, options) {
9178
- var value = validator.getFieldValue($field, 'zipCode');
9201
+ validate: function(validator, $field, options, validatorName) {
9202
+ var value = validator.getFieldValue($field, validatorName);
9179
9203
  if (value === '' || !options.country) {
9180
9204
  return true;
9181
9205
  }
@@ -9318,10 +9342,6 @@ if (typeof jQuery === 'undefined') {
9318
9342
 
9319
9343
  /**
9320
9344
  * Validate United Kingdom postcode
9321
- * Examples:
9322
- * - Standard: EC1A 1BB, W1A 1HQ, M1 1AA, B33 8TH, CR2 6XH, DN55 1PT
9323
- * - Special cases:
9324
- * AI-2640, ASCN 1ZZ, GIR 0AA
9325
9345
  *
9326
9346
  * @see http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
9327
9347
  * @param {String} value The postcode