Skip to content

Commit

Permalink
Merge pull request #1063 from shineability/master
Browse files Browse the repository at this point in the history
Fixes verbose = false on field level and field error events not triggered when verbose = false
  • Loading branch information
nghuuphuoc committed Nov 2, 2014
2 parents ccc7a0a + a49e36a commit f28d450
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/js/bootstrapValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,33 @@ if (typeof jQuery === 'undefined') {
$field.trigger($.Event(this.options.events.fieldSuccess), data);
}
// 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
this.$invalidFields = this.$invalidFields.add($field);

$field.trigger($.Event(this.options.events.fieldError), data);
}
},

_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
// ---
Expand Down Expand Up @@ -860,7 +879,7 @@ if (typeof jQuery === 'undefined') {
total = ('radio' === type || 'checkbox' === type) ? 1 : fields.length,
updateAll = ('radio' === type || 'checkbox' === type),
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,
validateResult;

Expand Down

0 comments on commit f28d450

Please sign in to comment.