您的位置:首页 > 其它

验证注册表单

2015-12-19 10:14 302 查看


在注册表单中,输入错误时提醒

Html:错误信息放入reg_error

<ol class=”reg_error”></ol>

Js:

$(‘#reg’).validate({

errorLabelContainer:’ol.reg_error’,

wrapper:li

rules:{

user:{

required:true,

minlength:2,},

pass:{

required:true,

minlength:6,

},

email:{

required:true,

email:true,

},

date:{}

},

highlight:function(element,errorClass){}

unhighlight:function(element,errorClass){

$(element).css(‘border’,’1px solid #ccc’);

$(element).parent().find(‘span’).html(‘ ’).addClass(‘succ’)

},

}

messages:{

user:{

required:”账号不得为空”,

minlength:”账号不得小于{0}位”

}}

})

showErrors:function(errorMap,errorList){

var errors=this.numberOfInvalids();

if(errors>0){

$(‘#reg’).dialog(‘option’,’height’,errors*20+340);}

else{

$(‘#reg’).dialog(‘option’,’height’, 340);

}

this.defaultShowErrors();

}

Css:

#reg ol{

margin:0;

padding:0 0 0 20px;

color:maroon;

}

#reg ol li{

Height:20px}

#reg succ{

Display:inline-block;

Background:url(../img/XXXX.png no-repeat);}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: