首页 > 其他 > 详细

cv.form.validator

时间:2014-09-11 14:00:32      阅读:214      评论:0      收藏:0      [点我收藏+]

有即时验证,加载完验证两种方式:
即时验证:

cv.form.validator(jQuery("#qq").val(),{
	  type:["require","intlength","int"],min:5,max:11,
	  errorFunction:function(obj,options){
		  switch(options.type){
			case "require" :{
				jQuery("#msg_qq").attr("class","tips_error").html("请输入常用的QQ号码!").show();
				break;
			}
			case "intlength" :{
				jQuery("#msg_qq").attr("class","tips_error").html("请输入常用的QQ号码!").show();
				break;
			}
			case "int":{
				jQuery("#msg_qq").attr("class","tips_error").html("请输入正确的QQ号码!").show();
				break;
			}
		}
	  },
	  successFunction:function(obj,options){
		  jQuery("#msg_qq").attr("class","tips_ok").html("").show();
	  }
});



加载完统一验证:
cv.form.validator.bind(jQuery("#shortTitle"),{
	type:["require"],
	successFunction:function(obj,options){
		_showMsg("#msg_shortTitle","tips_ok","");
	},
	errorFunction:function(obj,options){
		switch(options.type){
			case "require":{
				 _showMsg("#msg_shortTitle","tips_error","信息标题不能为空!");
				break;
			}
		}
	}
});
jQuery("#shortTitle").bind("blur",function(){
	if(jQuery("#shortTitle").val()){
		cv.form.validator(this);
	}
}).bind("focus",function(){
	 _showMsg("#msg_shortTitle","tips_info","请填写信息标题。");
});






cv.form.validator

原文:http://my.oschina.net/wrean/blog/312372

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!