---
title: "common-validator 验证框架使用"
author: "fackyou200"
date: "2013-10-12T12:47:52Z"
tags: []
categories: ["Web前端"]
slug: "common-validator"
draft: false
lastmod: "2013-10-14T20:00:49Z"
id: 1955731
url: "https://fackyou200.iteye.com/blog/1955731"
---

地址：[http://www.marsclan.org/html/product/component/javascript/common-validator/index.html](http://www.marsclan.org/html/product/component/javascript/common-validator/index.html)

 

能动态添加、删除验证。。。。

 

common-validator-2.2解决与jquery冲突问题。。。  至于把【common-validator-2.1.min.js】替换【common-validator-2.2.min.js】即可！！！！！！！！！！！！！

Alter单个提示：

common-validator-config 修改：

```
/**
 * <pre> 
 * @fileoverview
 *                      Copyright (c) www.MarsClan.org
 * ============================================================================
 * JavaScript   : 验证器配置文件
 * Version      : 2.1
 * Author       : 啸白腥
 * Date         : 2012-08-02
 * Dependences  : common-validator-2.1.min.js
 * Description  : 
 * 
 * ------------------------- Revision of history ------------------------------
 *  啸白腥@2012-08-15: 修改内容
 * 
 * 
 * ============================================================================
 * </pre>
 **/
(function($) {
  /**
   * 配置信息常量
   */
  var Global = {
    
    /**
     * 错误信息提示方式.
     */
    showErrorType : {
      ALERT : 1, //原始alert提示
      PANLE : 2, //在信息面板中提示
      STYLE : 3, //在验证失败的字段上显示
      LABEL : 4, //在信息标签中显示
      DIV   : 5  //在信息标签中显示
    }, 
    
    /**
     * 验证登记模式.
     */
    registerType : {
      ADD       : 0, //添加模式
      FORM      : 1, //表单生成模式
      ADD_FORM  : 2  //全模式。支持添加和表单两种模式
    }
  };
  
	$.Config = {
	  registerType           : Global.registerType.ADD_FORM, 
	  validateProperty       : "class", //通过控件元素进行添加验证时的元素属性
	  validateTitle          : "{id}_label", //字段名称
    isFocus                : true, //验证失败后是否会落焦点 
    isEnableSubValidator   : true, 
    titleSepartor          : ",", 
    isManyErrorMessage     : false, //验证失败后，错误信息是否一块显示
    showErrorType          : Global.showErrorType.ALERT,
    alert                  : function(msg) {
        window.alert(msg.split('\n')[0]);
      }
	};
})(jValidator);
```