浏览代码

non-verbose validation

Marin Bezhanov 11 年之前
父节点
当前提交
1ed5a94568
共有 1 个文件被更改,包括 15 次插入1 次删除
  1. 15 1
      src/js/bootstrapValidator.js

+ 15 - 1
src/js/bootstrapValidator.js

@@ -763,10 +763,16 @@
                     else if ('object' === typeof validateResult && validateResult.valid !== undefined && validateResult.message !== undefined) {
                         this.updateMessage(updateAll ? field : $field, validatorName, validateResult.message);
                         this.updateStatus(updateAll ? field : $field, validateResult.valid ? this.STATUS_VALID : this.STATUS_INVALID, validatorName);
+                        if (!validateResult.valid && !this.options.verbose) {
+                            break;
+                        }
                     }
                     // ... or a boolean value
                     else if ('boolean' === typeof validateResult) {
                         this.updateStatus(updateAll ? field : $field, validateResult ? this.STATUS_VALID : this.STATUS_INVALID, validatorName);
+                        if (!validateResult && !this.options.verbose) {
+                            break;
+                        }
                     }
                 }
             }
@@ -1641,7 +1647,15 @@
         live: 'enabled',
 
         // Map the field name with validator rules
-        fields: null
+        fields: null,
+		
+		// Whether to be verbose when validating a field or not.
+		// Possible values:
+		// - true:  when a field has multiple validators, all of them will be checked, and respectively - if errors occur in
+		//			multiple validators, all of them will be displayed to the user
+		// - false: when a field has multiple validators, validation for this field will be terminated upon the first encountered error.
+		// 			Thus, only the very first error message related to this field will be displayed to the user
+		verbose: true
     };
 
     // Available validators