Browse Source

#50: Don't validate disabled element

nghuuphuoc 12 years ago
parent
commit
0c349bd9f8
4 changed files with 12 additions and 5 deletions
  1. 1 0
      CHANGELOG.md
  2. 5 2
      dist/js/bootstrapValidator.js
  3. 1 1
      dist/js/bootstrapValidator.min.js
  4. 5 2
      src/js/bootstrapValidator.js

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@ __New features__:
 
 __Fixes__:
 
+* [#50: Don't validate disabled element](https://github.com/nghuuphuoc/bootstrapvalidator/issues/50)
 * [#51: Submit after submit doesn't work](https://github.com/nghuuphuoc/bootstrapvalidator/issues/51)
 * [#53: Fix notEmpty validator for radios and checkboxes](https://github.com/nghuuphuoc/bootstrapvalidator/issues/53)
 * [#62: The callback validator passes wrong parameter](https://github.com/nghuuphuoc/bootstrapvalidator/issues/62)

+ 5 - 2
dist/js/bootstrapValidator.js

@@ -101,8 +101,11 @@
             this._results[field] = {};
 
             var fields = this.$form.find('[name="' + field + '"]');
-            if (fields.length == 0) {
-                // We don't need to validate non-existing fields next time
+
+            // We don't need to validate ...
+            if (fields.length == 0                                  // ... non-existing fields
+                || (fields.length == 1 && fields.is(':disabled')))  // ... disabled field
+            {
                 delete this.options.fields[field];
                 delete this._dfds[field];
                 return;

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


+ 5 - 2
src/js/bootstrapValidator.js

@@ -100,8 +100,11 @@
             this._results[field] = {};
 
             var fields = this.$form.find('[name="' + field + '"]');
-            if (fields.length == 0) {
-                // We don't need to validate non-existing fields next time
+
+            // We don't need to validate ...
+            if (fields.length == 0                                  // ... non-existing fields
+                || (fields.length == 1 && fields.is(':disabled')))  // ... disabled field
+            {
                 delete this.options.fields[field];
                 delete this._dfds[field];
                 return;