diff --git a/js/tests/unit/validator.js b/js/tests/unit/validator.js index 64b63ad..8d6ce6e 100644 --- a/js/tests/unit/validator.js +++ b/js/tests/unit/validator.js @@ -603,6 +603,11 @@ $(function () { assert.equal($('#validated').text(), 'error', 'validation of skipped field was forced due to data-validate="true"') assert.equal($('#skipped').text(), '', 'validation of field was bypassed due to data-validate="false"') + $('[data-validate="true"]').attr('data-validate', false) + form.validator('update') + + assert.equal($('#validated').text(), '', 'error is cleared when data-validate="false" and the form is updated') + $.fn.validator.Constructor.INPUT_SELECTOR = inputSelector }) diff --git a/js/validator.js b/js/validator.js index 9fd8c46..2041ced 100644 --- a/js/validator.js +++ b/js/validator.js @@ -110,9 +110,13 @@ } Validator.prototype.update = function () { + var self = this + this.$inputs = this.$element.find(Validator.INPUT_SELECTOR) .add(this.$element.find('[data-validate="true"]')) - .not(this.$element.find('[data-validate="false"]')) + .not(this.$element.find('[data-validate="false"]') + .each(function () { self.clearErrors($(this)) }) + ) this.toggleSubmit()