jquery validation 动态添加校验规则

for(var a=0;a<oEle.length;a++){
//oEle[a].class='validate[required] radio';
//$("#offenseDictAndAgainstScopeDto").validate(); /sets up the validator
//$(oEle[a]).rules("add", "required");
if(oEle[a].type == "radio"){
$(oEle[a]).attr('class', 'validate[required] radio');
}
if(oEle[a].type == "radio" && oEle[a].value != "-1" && oEle[a].checked == true){
$(oEle[1]).attr('class', 'validate[required]');
}

if(oEle[a].type == "radio" && oEle[a].value == "-1" && oEle[a].checked == true){
$(oEle[1]).attr('class', '');
}
//alert(oEle[a].type);

}

猜你喜欢

转载自vernonchen163.iteye.com/blog/1986019