ソースを参照

#914: Improve behaviour of the identical validator

Phuoc Nguyen 11 年 前
コミット
778cb37924

+ 1 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@ __New Features__
 __Improvements__
 * [#823](https://github.com/nghuuphuoc/bootstrapvalidator/issues/823): The [hexColor](http://bootstrapvalidator.com/validators/hexColor/) validator only accepts 6 hex character values when using HTML 5 ```type='color'``` attribute
 * [#864](https://github.com/nghuuphuoc/bootstrapvalidator/pull/864): Coma separator handling in [greaterThan](http://bootstrapvalidator.com/validators/greaterThan/), [lessThan](http://bootstrapvalidator.com/validators/lessThan/) validators, thanks to [@mgibas](https://github.com/mgibas)
+* [#914](https://github.com/nghuuphuoc/bootstrapvalidator/issues/914): Improve behaviour of the [identical](http://bootstrapvalidator.com/validators/identical/) validator
 * [#999](https://github.com/nghuuphuoc/bootstrapvalidator/pull/999): Replace ',' with '.' to validate decimal numbers correct, thanks to [@johanronn77](https://github.com/johanronn77)
 * [#1002](https://github.com/nghuuphuoc/bootstrapvalidator/pull/1002): Put tooltip/popover on bottom if there is not enough space on top, thanks to [@jazzzz](https://github.com/jazzzz)
 

+ 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.3-dev, built on 2014-10-21 8:50:43 AM
+ * @version     v0.5.3-dev, built on 2014-10-21 3:55:22 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 10 - 5
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.3-dev, built on 2014-10-21 8:50:43 AM
+ * @version     v0.5.3-dev, built on 2014-10-21 3:55:22 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -4939,12 +4939,17 @@ if (typeof jQuery === 'undefined') {
                 return true;
             }
 
-            if (value === compareWith.val()) {
-                validator.updateStatus(options.field, validator.STATUS_VALID, 'identical');
+            var compareValue = compareWith.val();
+            if (compareValue === '') {
                 return true;
-            } else {
-                return false;
             }
+
+            if (value === compareValue) {
+                validator.updateStatus(compareWith, validator.STATUS_VALID, 'identical');
+                return true;
+            }
+
+            return false;
         }
     };
 }(window.jQuery));

ファイルの差分が大きいため隠しています
+ 3 - 3
dist/js/bootstrapValidator.min.js


+ 9 - 4
src/js/validator/identical.js

@@ -29,12 +29,17 @@
                 return true;
             }
 
-            if (value === compareWith.val()) {
-                validator.updateStatus(options.field, validator.STATUS_VALID, 'identical');
+            var compareValue = compareWith.val();
+            if (compareValue === '') {
                 return true;
-            } else {
-                return false;
             }
+
+            if (value === compareValue) {
+                validator.updateStatus(compareWith, validator.STATUS_VALID, 'identical');
+                return true;
+            }
+
+            return false;
         }
     };
 }(window.jQuery));