ソースを参照

Remove field from invalid fields after removing field

nghuuphuoc 12 年 前
コミット
aa0dfbb78f

+ 1 - 1
CHANGELOG.md

@@ -4,7 +4,7 @@
 
 * [#121](https://github.com/nghuuphuoc/bootstrapvalidator/issues/121): Add events for form validate successfully or not
 * [#195](https://github.com/nghuuphuoc/bootstrapvalidator/issues/195): Add events for field validation
-* [#235](https://github.com/nghuuphuoc/bootstrapvalidator/issues/235): Add new method ```getInvalidFields()``` that returns all invalid fields
+* [#211](https://github.com/nghuuphuoc/bootstrapvalidator/issues/211), [#235](https://github.com/nghuuphuoc/bootstrapvalidator/issues/235): Add new method ```getInvalidFields()``` that returns all invalid fields
 
 ## v0.4.5 (not released yet)
 

+ 13 - 7
dist/js/bootstrapValidator.js

@@ -404,7 +404,7 @@
          * Returning true means that the field will not be validated
          *
          * @param {jQuery} $field The field element
-         * @return {Boolean}
+         * @returns {Boolean}
          */
         _isExcluded: function($field) {
             if (this.options.excluded) {
@@ -572,7 +572,7 @@
         /**
          * Validate the form
          *
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         validate: function() {
             if (!this.options.fields) {
@@ -673,7 +673,7 @@
          * @param {String} field The field name
          * @param {String} status The status. Can be 'NOT_VALIDATED', 'VALIDATING', 'INVALID' or 'VALID'
          * @param {String} [validatorName] The validator name. If null, the method updates validity result for all validators
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         updateStatus: function(field, status, validatorName) {
             var fields = this.getFieldElements(field),
@@ -693,7 +693,7 @@
          * @param {jQuery} $field The field element
          * @param {String} status The status. Can be 'NOT_VALIDATED', 'VALIDATING', 'INVALID' or 'VALID'
          * @param {String} [validatorName] The validator name. If null, the method updates validity result for all validators
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         updateElementStatus: function($field, status, validatorName) {
             var that     = this,
@@ -894,6 +894,11 @@
                 index = this._cacheFields[field].index($field);
 
             (index == -1) ? (delete this._cacheFields[field]) : this._cacheFields[field].splice(index, 1);
+            // Remove from the list of invalid fields
+            index = this.$invalidFields.index($field);
+            if (index != -1) {
+                this.$invalidFields.splice(index, 1);
+            }
 
             if ('checkbox' == type || 'radio' == type) {
                 this._initField(field);
@@ -906,7 +911,7 @@
          * Reset the form
          *
          * @param {Boolean} resetFormData Reset current form data
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         resetForm: function(resetFormData) {
             var field, fields, total, type, validator;
@@ -943,7 +948,7 @@
          *
          * @param {String} field The field name
          * @param {Boolean} enabled Enable/Disable field validators
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         enableFieldValidators: function(field, enabled) {
             this.options.fields[field]['enabled'] = enabled;
@@ -1001,9 +1006,10 @@
         },
 
         /**
-         * Implement Luhn validation algorithm ((http://en.wikipedia.org/wiki/Luhn))
+         * Implement Luhn validation algorithm
          * Credit to https://gist.github.com/ShirtlessKirk/2134376
          *
+         * @see http://en.wikipedia.org/wiki/Luhn
          * @param {String} value
          * @returns {Boolean}
          */

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


+ 13 - 7
src/js/bootstrapValidator.js

@@ -403,7 +403,7 @@
          * Returning true means that the field will not be validated
          *
          * @param {jQuery} $field The field element
-         * @return {Boolean}
+         * @returns {Boolean}
          */
         _isExcluded: function($field) {
             if (this.options.excluded) {
@@ -571,7 +571,7 @@
         /**
          * Validate the form
          *
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         validate: function() {
             if (!this.options.fields) {
@@ -672,7 +672,7 @@
          * @param {String} field The field name
          * @param {String} status The status. Can be 'NOT_VALIDATED', 'VALIDATING', 'INVALID' or 'VALID'
          * @param {String} [validatorName] The validator name. If null, the method updates validity result for all validators
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         updateStatus: function(field, status, validatorName) {
             var fields = this.getFieldElements(field),
@@ -692,7 +692,7 @@
          * @param {jQuery} $field The field element
          * @param {String} status The status. Can be 'NOT_VALIDATED', 'VALIDATING', 'INVALID' or 'VALID'
          * @param {String} [validatorName] The validator name. If null, the method updates validity result for all validators
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         updateElementStatus: function($field, status, validatorName) {
             var that     = this,
@@ -893,6 +893,11 @@
                 index = this._cacheFields[field].index($field);
 
             (index == -1) ? (delete this._cacheFields[field]) : this._cacheFields[field].splice(index, 1);
+            // Remove from the list of invalid fields
+            index = this.$invalidFields.index($field);
+            if (index != -1) {
+                this.$invalidFields.splice(index, 1);
+            }
 
             if ('checkbox' == type || 'radio' == type) {
                 this._initField(field);
@@ -905,7 +910,7 @@
          * Reset the form
          *
          * @param {Boolean} resetFormData Reset current form data
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         resetForm: function(resetFormData) {
             var field, fields, total, type, validator;
@@ -942,7 +947,7 @@
          *
          * @param {String} field The field name
          * @param {Boolean} enabled Enable/Disable field validators
-         * @return {BootstrapValidator}
+         * @returns {BootstrapValidator}
          */
         enableFieldValidators: function(field, enabled) {
             this.options.fields[field]['enabled'] = enabled;
@@ -1000,9 +1005,10 @@
         },
 
         /**
-         * Implement Luhn validation algorithm ((http://en.wikipedia.org/wiki/Luhn))
+         * Implement Luhn validation algorithm
          * Credit to https://gist.github.com/ShirtlessKirk/2134376
          *
+         * @see http://en.wikipedia.org/wiki/Luhn
          * @param {String} value
          * @returns {Boolean}
          */