在表单元素中加入"drea-verify"属性来指定验证类型,加入"drea-tip"属性来指定验证失败的返回信息,例如:
注意:这些表单元素必须位于form元素内,且form元素有"drea-form"属性时,验证才会生效
需要同时满足多个验证时,使用英文逗号来分隔验证标识,例如:或者required,integer,testCheck1
//修改配置
VERY.extend({
//一个中文占多少长度
cht:2,
msgSec:'\n',
alertFunc:function(msg){
alert(msg);
}
});
VERY.addVerify("#testForm",{
testCheck1:function(v){
return v =='1' ? true : '请输入1';
},
testDivCheck: function(){
return $("input[name=checkTest]:checked").length > 1 ? true : "请至少勾选2个checkbox";
},
testDivRadio:function(){
return $("input[name=radioTest]:checked").length > 0 ? true : "请勾选radio";
}
});
$("#subtn").click(function (){
if(VERY.verify("#testForm")){
alert('验证通过');
}
});