Browse Source

Support type="range" HTML 5 attribute

nghuuphuoc 11 years ago
parent
commit
c36d1127a3

+ 2 - 1
CHANGELOG.md

@@ -38,9 +38,10 @@ HTML 5 attribute      | Validator
 ```maxlength="..."``` | [```stringLength``` validator](http://bootstrapvalidator.com/validators/string-length/)
 ```maxlength="..."``` | [```stringLength``` validator](http://bootstrapvalidator.com/validators/string-length/)
 ```pattern="..."```   | [```regexp``` validator](http://bootstrapvalidator.com/validators/regexp/)
 ```pattern="..."```   | [```regexp``` validator](http://bootstrapvalidator.com/validators/regexp/)
 ```required```        | [```notEmpty``` validator](http://bootstrapvalidator.com/validators/not-empty/)
 ```required```        | [```notEmpty``` validator](http://bootstrapvalidator.com/validators/not-empty/)
+```type="color"```    | [```hexColor``` validator](http://bootstrapvalidator.com/validators/hex-color/)
 ```type="email"```    | [```emailAddress``` validator](http://bootstrapvalidator.com/validators/email-address/)
 ```type="email"```    | [```emailAddress``` validator](http://bootstrapvalidator.com/validators/email-address/)
+```type="range"```    | [```between``` validator](http://bootstrapvalidator.com/validators/between/)
 ```type="url"```      | [```uri``` validator](http://bootstrapvalidator.com/validators/uri/)
 ```type="url"```      | [```uri``` validator](http://bootstrapvalidator.com/validators/uri/)
-```type="color"```    | [```hexColor``` validator](http://bootstrapvalidator.com/validators/hex-color/)
 
 
 * [#74](https://github.com/nghuuphuoc/bootstrapvalidator/issues/74), [#103](https://github.com/nghuuphuoc/bootstrapvalidator/issues/103), [#122](https://github.com/nghuuphuoc/bootstrapvalidator/issues/122): Set the custom trigger event
 * [#74](https://github.com/nghuuphuoc/bootstrapvalidator/issues/74), [#103](https://github.com/nghuuphuoc/bootstrapvalidator/issues/103), [#122](https://github.com/nghuuphuoc/bootstrapvalidator/issues/122): Set the custom trigger event
 
 

+ 4 - 0
demo/html5.html

@@ -76,6 +76,10 @@
                                    min="10" data-bv-greaterthan-inclusive="false" data-bv-greaterthan-message="The input must be greater than or equal to 10"
                                    min="10" data-bv-greaterthan-inclusive="false" data-bv-greaterthan-message="The input must be greater than or equal to 10"
                                    max="100" data-bv-lessthan-inclusive="true" data-bv-lessthan-message="The input must be less than 100"
                                    max="100" data-bv-lessthan-inclusive="true" data-bv-lessthan-message="The input must be less than 100"
                                     />
                                     />
+                            <!--<input type="range" class="form-control" name="age"
+                                   required
+                                   min="10" max="100" data-bv-between-message="The input must be between 10 and 100"
+                                    />-->
                         </div>
                         </div>
                     </div>
                     </div>
 
 

+ 11 - 0
dist/js/bootstrapValidator.js

@@ -728,6 +728,17 @@
             inclusive: 'inclusive'
             inclusive: 'inclusive'
         },
         },
 
 
+        enableByHtml5: function($field) {
+            if ('range' == $field.attr('type')) {
+                return {
+                    min: $field.attr('min'),
+                    max: $field.attr('max')
+                };
+            }
+
+            return false;
+        },
+
         /**
         /**
          * Return true if the input value is between (strictly or not) two given numbers
          * Return true if the input value is between (strictly or not) two given numbers
          *
          *

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


+ 11 - 0
src/js/validator/between.js

@@ -7,6 +7,17 @@
             inclusive: 'inclusive'
             inclusive: 'inclusive'
         },
         },
 
 
+        enableByHtml5: function($field) {
+            if ('range' == $field.attr('type')) {
+                return {
+                    min: $field.attr('min'),
+                    max: $field.attr('max')
+                };
+            }
+
+            return false;
+        },
+
         /**
         /**
          * Return true if the input value is between (strictly or not) two given numbers
          * Return true if the input value is between (strictly or not) two given numbers
          *
          *