Browse Source

Merge pull request #813 from emilchristensen/feature_validator_html5_minlength

Adds HTML5 minlength support
Phuoc Nguyen 11 years ago
parent
commit
d0d9bd591f

+ 1 - 1
demo/html5.html

@@ -43,7 +43,7 @@
                                    data-bv-message="The username is not valid"
                                    required data-bv-notempty-message="The username is required and cannot be empty"
                                    pattern="[a-zA-Z0-9_\.]+" data-bv-regexp-message="The username can only consist of alphabetical, number, dot and underscore"
-                                    />
+                                   minlength="5" />
                         </div>
                     </div>
 

+ 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.2-dev, built on 2014-09-10 2:14:58 PM
+ * @version     v0.5.2-dev, built on 2014-09-10 12:12:27 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 8 - 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.2-dev, built on 2014-09-10 2:14:58 PM
+ * @version     v0.5.2-dev, built on 2014-09-10 12:12:27 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -5924,14 +5924,17 @@ if (typeof jQuery === 'undefined') {
         },
 
         enableByHtml5: function($field) {
+            var html5Validators = {};
             var maxLength = $field.attr('maxlength');
             if (maxLength) {
-                return {
-                    max: parseInt(maxLength, 10)
-                };
+                html5Validators.max = parseInt(maxLength, 10);
             }
 
-            return false;
+            var minLength = $field.attr('minlength');
+            if (minLength) {
+                html5Validators.min = parseInt(minLength, 10);
+            }
+            return !$.isEmptyObject(html5Validators) && html5Validators;
         },
 
         /**

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


+ 7 - 4
src/js/validator/stringLength.js

@@ -14,14 +14,17 @@
         },
 
         enableByHtml5: function($field) {
+            var html5Validators = {};
             var maxLength = $field.attr('maxlength');
             if (maxLength) {
-                return {
-                    max: parseInt(maxLength, 10)
-                };
+                html5Validators.max = parseInt(maxLength, 10);
             }
 
-            return false;
+            var minLength = $field.attr('minlength');
+            if (minLength) {
+                html5Validators.min = parseInt(minLength, 10);
+            }
+            return !$.isEmptyObject(html5Validators) && html5Validators;
         },
 
         /**