Browse Source

#822: Add color validator, thanks to @emilchristensen

Phuoc Nguyen 11 years ago
parent
commit
d9ceb3fc31

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@
 
 
 __New Features__
 __New Features__
 * [#807](https://github.com/nghuuphuoc/bootstrapvalidator/issues/807), [#821](https://github.com/nghuuphuoc/bootstrapvalidator/pull/821): Add ```min```, ```max``` options for the [date](http://bootstrapvalidator.com/validators/date/) validator, thanks to [@Arkni](https://github.com/Arkni)
 * [#807](https://github.com/nghuuphuoc/bootstrapvalidator/issues/807), [#821](https://github.com/nghuuphuoc/bootstrapvalidator/pull/821): Add ```min```, ```max``` options for the [date](http://bootstrapvalidator.com/validators/date/) validator, thanks to [@Arkni](https://github.com/Arkni)
+* [#822](https://github.com/nghuuphuoc/bootstrapvalidator/pull/822): Add color validator, thanks to [@emilchristensen](https://github.com/emilchristensen)
 * [#844](https://github.com/nghuuphuoc/bootstrapvalidator/pull/844), [#874](https://github.com/nghuuphuoc/bootstrapvalidator/pull/874): The [stringLength](http://bootstrapvalidator.com/validators/stringLength/) validator adds option to evaluate length in UTF-8 bytes, thanks to [@thx2001r](https://github.com/thx2001r)
 * [#844](https://github.com/nghuuphuoc/bootstrapvalidator/pull/844), [#874](https://github.com/nghuuphuoc/bootstrapvalidator/pull/874): The [stringLength](http://bootstrapvalidator.com/validators/stringLength/) validator adds option to evaluate length in UTF-8 bytes, thanks to [@thx2001r](https://github.com/thx2001r)
 
 
 __Document__
 __Document__

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

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

+ 1 - 1
dist/js/bootstrapValidator.js

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

File diff suppressed because it is too large
+ 5 - 5
dist/js/bootstrapValidator.min.js


+ 5 - 1
src/js/validator/hexColor.js

@@ -18,7 +18,11 @@
          * @returns {Boolean}
          * @returns {Boolean}
          */
          */
         validate: function(validator, $field, options) {
         validate: function(validator, $field, options) {
-            return $.fn.bootstrapValidator.validators.color._hexColor(validator, $field, options);
+            var value = $field.val();
+            if (value === '') {
+                return true;
+            }
+            return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(value);
         }
         }
     };
     };
 }(window.jQuery));
 }(window.jQuery));