登陆验证的插件
验证插件的使用方法
1、需要进入文件jquery和jq_register.js(格式验证)、count_register(倒计时)
<scriptsrc="jquery-1.11.3.min.js"></script><scriptsrc="jq_register.js"></script><scriptsrc="count_register.js"></script>
2、html部分
需要验证什么格式就对应加什么class,class可以自己命名也可以用默认的class。
<divclass="register"><inputclass="crequiredcchinese"type="text"placeholder="请输入姓名"index="1"></input><inputclass="cpasswordcrequired"type="text"placeholder="请输入密码"index="2"></input><inputclass="cpasswordAgincrequired"type="text"placeholder="请再次输入密码"index="3"></input><inputclass="cemailcrequired"type="email"placeholder="请输入邮箱"index="4"></input><inputclass="cphonecnumber"type="text"placeholder="请输入电话号码"index="5"></input><div><p>helloworld!</p>
3、验证部分
验证required部分,需要给每一个元素都加上类名crequired,同时加上索引index,对应的值就可以在回调函数中判断。
$("p").click(function(){$(".register").register({required:true,norequiredCallBack:function(obj){if(obj==1)console.log("姓名不能为空");if(obj==2)console.log("密码不能为空");if(obj==3)console.log("确认密码不能为空");if(obj==4)console.log("邮箱不能为空");if(obj==5)console.log("电话号码不能为空");}});})
验证其他的,以email为例,直接加上类名cemail,或者自己定义一个,只要在register函数中把emailclass的属性重新定义过就行了。
<inputclass="cemailcrequired"type="email"placeholder="请输入邮箱"index="4"></input>
<inputclass="youxiangcrequired"type="email"placeholder="请输入邮箱"index="4"></input>
$("p").click(function(){$(".register").register({email:true,emailclass:"youxiang",noemailCallBack:function(){console.log("邮箱格式不正确");},});})
4、验证成功的回调函数
$("p").click(function(){$(".register").register({email:true,noemailCallBack:function(){console.log("邮箱格式不正确");},successCallBack:function(){//ajax写在这里}});})
5、返回值部分
返回值有true和false,ture为验证成功,false为验证不成功
$("p").click(function(){varregisterli=$(".register").register({email:true,noemailCallBack:function(){console.log("邮箱格式不正确");},successCallBack:function(){//ajax写在这里}});console.log(registerli);})
倒计时使用
Html部分
<aclass="getgetCode">获取验证码</a>
$(".getCode").countRegister({count:60,timeStartCallback:function(){},timeOutCallback:function(){}})附件:http://down.51cto.com/data/2366709
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。