Browse Source

#14, #57: Support HTML5 color input

phuoc 12 years ago
parent
commit
8a1d33b186

+ 7 - 0
demo/html5.html

@@ -61,6 +61,13 @@
                     </div>
                     </div>
 
 
                     <div class="form-group">
                     <div class="form-group">
+                        <label class="col-lg-3 control-label">Fav color</label>
+                        <div class="col-lg-3">
+                            <input class="form-control" name="color" type="color" required data-bv-hexcolor-message="The input is not a valid color code" />
+                        </div>
+                    </div>
+
+                    <div class="form-group">
                         <label class="col-lg-3 control-label">Age</label>
                         <label class="col-lg-3 control-label">Age</label>
                         <div class="col-lg-2">
                         <div class="col-lg-2">
                             <input type="text" class="form-control" name="age"
                             <input type="text" class="form-control" name="age"

+ 4 - 0
dist/js/bootstrapValidator.js

@@ -1171,6 +1171,10 @@
 }(window.jQuery));
 }(window.jQuery));
 ;(function($) {
 ;(function($) {
     $.fn.bootstrapValidator.validators.hexColor = {
     $.fn.bootstrapValidator.validators.hexColor = {
+        enableByHtml5: function($field) {
+            return ('color' == $field.attr('type'));
+        },
+
         /**
         /**
          * Return true if the input value is a valid hex color
          * Return true if the input value is a valid hex color
          *
          *

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


+ 4 - 0
src/js/validator/hexColor.js

@@ -1,5 +1,9 @@
 (function($) {
 (function($) {
     $.fn.bootstrapValidator.validators.hexColor = {
     $.fn.bootstrapValidator.validators.hexColor = {
+        enableByHtml5: function($field) {
+            return ('color' == $field.attr('type'));
+        },
+
         /**
         /**
          * Return true if the input value is a valid hex color
          * Return true if the input value is a valid hex color
          *
          *