验证注册表单
2015-12-19 10:14
351 查看
在注册表单中,输入错误时提醒
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);}
在注册表单中,输入错误时提醒
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);}
相关文章推荐
- 最大似然估计(MLE)的一些公式与定理(python实践)
- 个人明年求职的思考——记于十二月十九
- Android SDK安装、Android版本下载
- 递归程序如何实现及其原理?
- C# 选择结构 if、if..else、if..elseif...else、switch
- Android开发中验证码的生成
- Prism 订阅事件 IEventAggregator 说明
- show full process 查询状态
- 验证插件
- 我们为什么应该坚持写博客
- 【Linux】利用C语言文件流复制单一文件
- iis上json解析失败404
- PHP MySQLi的使用
- 理解LSTM网络(翻译)
- 黑马程序员--java中File操作的一点小问题
- Android之异步加载网络图片
- C语言逗号运算符和逗号表达式
- Memcached 基础理论
- Hadoop2.x配置即测试
- 简单讲解iOS应用开发中的MD5加密的相关使用