Browse Source

Merge pull request #1063 from shineability/master

Fixes verbose = false on field level and field error events not triggered when verbose = false
Phuoc Nguyen 11 years ago
parent
commit
f28d450ba8
1 changed files with 21 additions and 2 deletions
  1. 21 2
      src/js/bootstrapValidator.js

+ 21 - 2
src/js/bootstrapValidator.js

@@ -735,7 +735,7 @@ if (typeof jQuery === 'undefined') {
                 $field.trigger($.Event(this.options.events.fieldSuccess), data);
                 $field.trigger($.Event(this.options.events.fieldSuccess), data);
             }
             }
             // If all validators are completed and there is at least one validator which doesn't pass
             // If all validators are completed and there is at least one validator which doesn't pass
-            else if (counter[this.STATUS_NOT_VALIDATED] === 0 && counter[this.STATUS_VALIDATING] === 0 && counter[this.STATUS_INVALID] > 0) {
+            else if ((counter[this.STATUS_NOT_VALIDATED] === 0 || !this._isVerboseField(field)) && counter[this.STATUS_VALIDATING] === 0 && counter[this.STATUS_INVALID] > 0) {
                 // Add to the list of invalid fields
                 // Add to the list of invalid fields
                 this.$invalidFields = this.$invalidFields.add($field);
                 this.$invalidFields = this.$invalidFields.add($field);
 
 
@@ -743,6 +743,25 @@ if (typeof jQuery === 'undefined') {
             }
             }
         },
         },
 
 
+        _isVerboseField: function(field)
+        {
+            if (this.options.fields[field].verbose === 'true' || this.options.fields[field].verbose === true)
+            {
+                return true;
+            }
+            else if (this.options.fields[field].verbose === 'false' || this.options.fields[field].verbose === false)
+            {
+                return false;
+            }
+
+            return this._isVerbose();
+        },
+
+        _isVerbose: function()
+        {
+            return this.options.verbose === 'true' || this.options.verbose === true;
+        },
+
         // ---
         // ---
         // Public methods
         // Public methods
         // ---
         // ---
@@ -860,7 +879,7 @@ if (typeof jQuery === 'undefined') {
                 total      = ('radio' === type || 'checkbox' === type) ? 1 : fields.length,
                 total      = ('radio' === type || 'checkbox' === type) ? 1 : fields.length,
                 updateAll  = ('radio' === type || 'checkbox' === type),
                 updateAll  = ('radio' === type || 'checkbox' === type),
                 validators = this.options.fields[field].validators,
                 validators = this.options.fields[field].validators,
-                verbose    = this.options.fields[field].verbose === 'true' || this.options.fields[field].verbose === true || this.options.verbose === 'true' || this.options.verbose === true,
+                verbose    = this._isVerboseField(field),
                 validatorName,
                 validatorName,
                 validateResult;
                 validateResult;