Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
clearing errors on a field with data-validate=“false” upon .validator…
Browse files Browse the repository at this point in the history
…(‘update’). refs #387
  • Loading branch information
1000hz committed Dec 8, 2016
1 parent 2f49477 commit 7004d07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions js/tests/unit/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
6 changes: 5 additions & 1 deletion js/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 7004d07

Please sign in to comment.