浏览代码

#292: Fix identical validator issue with not clearing ```has-error``` class, thanks to @alavers

nghuuphuoc 11 年之前
父节点
当前提交
b3204731ae
共有 5 个文件被更改,包括 24 次插入18 次删除
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 10 8
      dist/js/bootstrapValidator.js
  4. 2 2
      dist/js/bootstrapValidator.min.js
  5. 10 8
      src/js/bootstrapValidator.js

+ 1 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@
 * [#282](https://github.com/nghuuphuoc/bootstrapvalidator/issues/282): Use error message that is returned from [```callback```](http://bootstrapvalidator.com/validators/callback/), [```remote```](http://bootstrapvalidator.com/validators/remote/) validators
 * [#287](https://github.com/nghuuphuoc/bootstrapvalidator/issues/287): Only send the submit button which is clicked. It's an enhancement for [#238](https://github.com/nghuuphuoc/bootstrapvalidator/issues/238)
 * [#288](https://github.com/nghuuphuoc/bootstrapvalidator/issues/288): Fix [```date``` validator](http://bootstrapvalidator.com/validators/date/) issue on IE8
+* [#292](https://github.com/nghuuphuoc/bootstrapvalidator/pull/292): Fix identical validator issue with not clearing ```has-error``` class, thanks to [@alavers](https://github.com/alavers)
 
 ## v0.4.5 (2015-05-15)
 

+ 1 - 0
README.md

@@ -97,6 +97,7 @@ The __BootstrapValidator__ plugin is written by Nguyen Huu Phuoc, aka @nghuuphuo
 Big thanks to the contributors:
 
 * [@adgrafik](https://github.com/adgrafik)
+* [@alavers](https://github.com/alavers)
 * [@easonhan007](https://github.com/easonhan007)
 * [@emilchristensen](https://github.com/emilchristensen)
 * [@evilchili](https://github.com/evilchili)

+ 10 - 8
dist/js/bootstrapValidator.js

@@ -805,18 +805,19 @@
                         $container.find('[data-bv-field]').each(function() {
                             var field = $(this).attr('data-bv-field');
                             if (!map[field]) {
-                                map[field] = $(this).data('bv.messages');
+                                map[field] = $(this);
                             }
                         });
 
                         for (var field in map) {
-                            if (map[field]
-                                    .find('.help-block[data-bv-validator][data-bv-for="' + field + '"]')
-                                    .filter(function() {
-                                        var display = $(this).css('display'), v = $(this).attr('data-bv-validator');
-                                        return ('block' == display) || ($field.data('bv.result.' + v) && $field.data('bv.result.' + v) != that.STATUS_VALID);
-                                    })
-                                    .length != 0)
+                            var $f = map[field];
+                            if ($f.data('bv.messages')
+                                  .find('.help-block[data-bv-validator][data-bv-for="' + field + '"]')
+                                  .filter(function() {
+                                      var v = $(this).attr('data-bv-validator');
+                                      return ($f.data('bv.result.' + v) && $f.data('bv.result.' + v) != that.STATUS_VALID);
+                                  })
+                                  .length != 0)
                             {
                                 // The field is not valid
                                 return false;
@@ -825,6 +826,7 @@
 
                         return true;
                     };
+
                     $parent.removeClass('has-error has-success').addClass(isValidContainer($parent) ? 'has-success' : 'has-error');
                     if ($tab) {
                         $tab.removeClass('bv-tab-success').removeClass('bv-tab-error').addClass(isValidContainer($tabPane) ? 'bv-tab-success' : 'bv-tab-error');

文件差异内容过多而无法显示
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 10 - 8
src/js/bootstrapValidator.js

@@ -804,18 +804,19 @@
                         $container.find('[data-bv-field]').each(function() {
                             var field = $(this).attr('data-bv-field');
                             if (!map[field]) {
-                                map[field] = $(this).data('bv.messages');
+                                map[field] = $(this);
                             }
                         });
 
                         for (var field in map) {
-                            if (map[field]
-                                    .find('.help-block[data-bv-validator][data-bv-for="' + field + '"]')
-                                    .filter(function() {
-                                        var display = $(this).css('display'), v = $(this).attr('data-bv-validator');
-                                        return $field.data('bv.result.' + v) && $field.data('bv.result.' + v) != that.STATUS_VALID;
-                                    })
-                                    .length != 0)
+                            var $f = map[field];
+                            if ($f.data('bv.messages')
+                                  .find('.help-block[data-bv-validator][data-bv-for="' + field + '"]')
+                                  .filter(function() {
+                                      var v = $(this).attr('data-bv-validator');
+                                      return ($f.data('bv.result.' + v) && $f.data('bv.result.' + v) != that.STATUS_VALID);
+                                  })
+                                  .length != 0)
                             {
                                 // The field is not valid
                                 return false;
@@ -824,6 +825,7 @@
 
                         return true;
                     };
+
                     $parent.removeClass('has-error has-success').addClass(isValidContainer($parent) ? 'has-success' : 'has-error');
                     if ($tab) {
                         $tab.removeClass('bv-tab-success').removeClass('bv-tab-error').addClass(isValidContainer($tabPane) ? 'bv-tab-success' : 'bv-tab-error');