浏览代码

#345, #454: The different validator allows more than a 2-way comparison, thanks to @AlaskanShade

phuoc 11 年之前
父节点
当前提交
c1f6756704
共有 4 个文件被更改,包括 24 次插入14 次删除
  1. 4 0
      CHANGELOG.md
  2. 1 1
      dist/css/bootstrapValidator.min.css
  3. 16 10
      dist/js/bootstrapValidator.js
  4. 3 3
      dist/js/bootstrapValidator.min.js

+ 4 - 0
CHANGELOG.md

@@ -2,6 +2,10 @@
 
 ## v0.5.2 (not released yet)
 
+__Improvements__
+
+* [#345](https://github.com/nghuuphuoc/bootstrapvalidator/issues/345), [#454](https://github.com/nghuuphuoc/bootstrapvalidator/pull/454): The [different](http://bootstrapvalidator.com/validators/different/) validator allows more than a 2-way comparison, thanks to [@AlaskanShade](https://github.com/AlaskanShade)
+
 __Language Packages__
 
 * [#712](https://github.com/nghuuphuoc/bootstrapvalidator/pull/712): Swedish language package, thanks to [@ulsa](https://github.com/ulsa)

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-08-24 10:44:05 AM
+ * @version     v0.5.2-dev, built on 2014-08-24 11:29:16 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 16 - 10
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-08-24 10:44:05 AM
+ * @version     v0.5.2-dev, built on 2014-08-24 11:29:16 AM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -2500,17 +2500,23 @@
                 return true;
             }
 
-            var compareWith = validator.getFieldElements(options.field);
-            if (compareWith === null || compareWith.length === 0) {
-                return true;
-            }
+            var fields  = options.field.split(','),
+                isValid = true;
 
-            if (value !== compareWith.val()) {
-                validator.updateStatus(options.field, validator.STATUS_VALID, 'different');
-                return true;
-            } else {
-                return false;
+            for (var i = 0; i < fields.length; i++) {
+                var compareWith = validator.getFieldElements(fields[i]);
+                if (compareWith == null || compareWith.length === 0) {
+                    continue;
+                }
+
+                if (value === compareWith.val()) {
+                    isValid = false;
+                } else {
+                    validator.updateStatus(fields[i], validator.STATUS_VALID, 'different');
+                }
             }
+
+            return isValid;
         }
     };
 }(window.jQuery));

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