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

don't clear error if another input has errors inside a same form group. #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions js/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@
var $block = $group.find('.help-block.with-errors')
var $feedback = $group.find('.form-control-feedback')

// check that no other input in same group has error
var $otherHaserror = false
$group.find(':input').each(function($i, $other) {
var $errors = $($other).data('bs.validator.errors')
if ($errors && $errors.length) {
$otherHaserror = true
return false
}
})
if ($otherHaserror)
return;

$block.html($block.data('bs.validator.originalContent'))
$group.removeClass('has-error')

Expand Down