ソースを参照

#14, #57: Support HTML 5 min attribute

phuoc 12 年 前
コミット
a5f52c22df

+ 4 - 1
demo/html5.html

@@ -63,7 +63,10 @@
                     <div class="form-group">
                         <label class="col-lg-3 control-label">Age</label>
                         <div class="col-lg-2">
-                            <input type="text" class="form-control" name="age" max="100" required data-bv-lessthan-inclusive="true" data-bv-lessthan-message="The input must be less than 100" />
+                            <input type="text" class="form-control" name="age"
+                                   min="10" required data-bv-greaterthan-inclusive="false" data-bv-greaterthan-message="The input must be greater than or equal to 10"
+                                   max="100" required data-bv-lessthan-inclusive="true" data-bv-lessthan-message="The input must be less than 100"
+                                    />
                         </div>
                     </div>
 

+ 13 - 0
dist/js/bootstrapValidator.js

@@ -1135,6 +1135,19 @@
 }(window.jQuery));
 ;(function($) {
     $.fn.bootstrapValidator.validators.greaterThan = {
+        html5Attributes: ['message', 'value', 'inclusive'],
+
+        enableByHtml5: function($field) {
+            var min = $field.attr('min');
+            if (min) {
+                return {
+                    value: min
+                };
+            }
+
+            return false;
+        },
+
         /**
          * Return true if the input value is greater than or equals to given number
          *

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


+ 13 - 0
src/js/validator/greaterThan.js

@@ -1,5 +1,18 @@
 (function($) {
     $.fn.bootstrapValidator.validators.greaterThan = {
+        html5Attributes: ['message', 'value', 'inclusive'],
+
+        enableByHtml5: function($field) {
+            var min = $field.attr('min');
+            if (min) {
+                return {
+                    value: min
+                };
+            }
+
+            return false;
+        },
+
         /**
          * Return true if the input value is greater than or equals to given number
          *