浏览代码

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 年之前
父节点
当前提交
cfa8f5a797
共有 1 个文件被更改,包括 32 次插入0 次删除
  1. 32 0
      src/js/bootstrapValidator.js

+ 32 - 0
src/js/bootstrapValidator.js

@@ -520,6 +520,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;
+                    	            
         }
     };