From 68889bfb532c0fcc0b6cd8171afa52c7d6aa31d8 Mon Sep 17 00:00:00 2001 From: Romain FLIEDEL Date: Sun, 12 Apr 2015 20:18:30 +0200 Subject: [PATCH] don't clear error if another input has errors inside a same form group. --- js/validator.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/validator.js b/js/validator.js index f59a6b7..d7a21c2 100644 --- a/js/validator.js +++ b/js/validator.js @@ -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')