Browse Source

Update bootstrapValidator.js

Added two new public methods: addField and removeField. The first adds a new field validation options, and the second removes it.
jcnmulio 11 years ago
parent
commit
6b1c1b70e3
1 changed files with 32 additions and 0 deletions
  1. 32 0
      dist/js/bootstrapValidator.js

+ 32 - 0
dist/js/bootstrapValidator.js

@@ -521,6 +521,38 @@
             this.updateStatus(field, this.STATUS_NOT_VALIDATED, null);
 
             return this;
+        },
+        
+         /**
+         * Add a new field validation
+         *
+         * @param {String} field The field name
+         * @param {Object} Map the field name with validator rules
+         * 
+         * @return {BootstrapValidator}
+         */
+        addField: function(field, properties) {
+
+            this.options.fields[field] = properties;                    	           
+            this._initField(field);
+            
+            return this;
+                    	            
+        },
+        
+        /**
+         * Remove a field validation
+         *
+         * @param {String} field The field name 
+         * 
+         * @return {BootstrapValidator}
+         */
+        removeField: function(field) {
+
+        	delete this.options.fields[field];
+            
+            return this;
+                    	            
         }
     };