jquery.validate.js的remote用法
<script>
$(function(){
$("#myform").validate(
{ rules: {
name:{required:true,rangelength:[6,20],
remote:{ //验证用户名是否存在
type:"POST",
url:"loginVerifyAction", //servlet
data:{
name:function(){return $("#name").val();}
}
}
},
password: {required:true,minlength:6},
repassword: {required:true,equalTo:"#password"},
veryCode: {required:true,
remote:{
type:"POST",
url:"valCodeAction",
data:{
veryCode:function(){return $("#veryCode").val();}
}
}
}
},
messages: {
name:{required:"用户名不能为空!",rangelength:jQuery.format("用户名位数必须在{0}到{1}字符之间!"),remote:jQuery.format("用户名已经被注册")},
password: {required:"密码不能为空!",minlength:jQuery.format("密码位数必须大于等于6个字符!")},
repassword: {required:"确认密码不能为空!",equalTo:"确认密码和密码不一致!"},
veryCode: {required:"请输入验证码",remote:jQuery.format("验证码错误")}
}
});
}); </script> servlet代码: //验证用户名是否存在 public class LoginVerifyAction extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { response.reset();
response.setContentType("text/html;charset=UTF-8");
//业务逻辑操作countByParams得到值并存储到num中
if(num!=0){
response.getWriter().print(false);
}
else{
response.getWriter().print(true);
}
}
} //验证验证码 public class ValCodeAction extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
//得到验证码的操作请看另一篇文章 :验证码
response.setContentType("text/html;charset=UTF-8");
String validateC = request.getSession().getAttribute("validateCode").toString().trim();
String veryCode = request.getParameter("veryCode").trim();
if(veryCode.equals(validateC)){
response.getWriter().print(true);
}else{
response.getWriter().print(false);
}
} xml中的配置 : 忽略。。。
jquery.validate.js的remote用法的更多相关文章
- (转)jquery.validate.js 的 remote 后台验证
之前已经有一篇关于jquery.validate.js验证的文章,还不太理解的可以先看看:jQuery Validate 表单验证(这篇文章只是介绍了一下如何实现前台验证,并没有涉及后台验证remot ...
- jquery.validate.js 表单验证简单用法
引入jquery.validate.js插件以及Jquery,在最后加上这个插件的方法名来引用.$('form').validate(); <!DOCTYPE html PUBLIC " ...
- jquery validate.js表单验证的基本用法入门
这里转载一篇前辈写的文章,在我自己的理解上修改了一下,仅作记录. 先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript&quo ...
- jquery.validate.js remote (php)
网上的人不厚道呀 validate 这玩意的异步是 返回的 echo 'true' 或者 echo 'false';很少有人说呀~.~ 转载了一篇原文: jquery.validate.js对于数 ...
- jquery.validate.js表单验证 jquery.validate.js的用法
jquery.validate.js这个插件已经用了2年多了,是一个不可多得的表单验证最方便快捷的插件.基于jquery的小插件,基本小白一学就会上手,对于项目表单页面比较多,元素比较多的校验,该插件 ...
- jquery.validate.js使用说明——后台添加用户邮箱功能:非空、不能重复、格式正确
重点内容为: jQuery验证控件jquery.validate.js使用说明+中文API[http://www.tuicool.com/articles/iABvI3] 简单教程可以参考[jQue ...
- 表单验证插件之jquery.validate.js
提到表单验证的插件,第一个想到的就是jquery.validate.js,所以小生想在这里稍微详细地说一下这款插件的具体使用方法,便于理解,我直接附上整段demo的代码(没怎么调样式,主要是看js): ...
- jQuery验证控件jquery.validate.js使用说明
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- jquery.validate.js插件使用
jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...
随机推荐
- [Effective JavaScript 笔记]第58条:区分数组对象和类数组对象
示例 设想有两个不同类的API.第一个是位向量:有序的位集合 var bits=new BitVector(); bits.enable(4); bits.enable([1,3,8,17]); bi ...
- MFC 最大化 的时候控件 按比例变大
在dlg类头文件中声明CPoint Old; 在BEGIN_MESSAGE_MAP()和END_MESSAGE_MAP()声明一个映射:ON_WM_SIZE() 这样以后就可以在M_SIZE事件的时候 ...
- Kalendar server Beijing Tiandiyuandian Technology Limited 果然是木马
我的Windows 7 系统,在开始菜单里面输入msconfig ,回车打开系统配置,隐藏所有Microsoft的进程,在服务和启动项里面都有 Kalendar server Beijing Ti ...
- git初学者这样就行了。
Create a new repository on the command line touch README.md git init git add README.md git commit -m ...
- Centos下安装mysql 总结
一.MySQL安装 Centos下安装mysql 请点开:http://www.centoscn.com/CentosServer/sql/2013/0817/1285.html 二.MySQL的几个 ...
- tesseract3.02识别验证码需要注意的问题
1.安装tesseract3.02后,在命令行里输入tesseract,看能否出现使用方法,不出现则是环境变量问题,可调整其顺序. 2.找到如下文件 C:\Python27\Lib\site-pack ...
- 54. 八皇后问题[eight queens puzzle]
[本文链接] http://www.cnblogs.com/hellogiser/p/eight-queens-puzzle.html [题目] 在8×8的国际象棋上摆放八个皇后,使其不能相互攻击,即 ...
- iOS CALayer动画中使用的3个tree
在网上经常看到关于layer的tree的描述,不太理解,今天找到了官方文档,原文在Core Animation Programming Guide 中. Layer Trees Reflect Dif ...
- MySQL的LIMIT与分页优化
在系统中需要进行分页操作的时候,我们通常会使用LIMIT加上偏移量的办法实现,同时加上合适的ORDER BY子句.如果有对应的索引,通常效率会不错,否则,MySQL需要做大量的文件排序操作. 一个非常 ...
- linux下重启tomcat、实时查看tomcat运行日志
在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh 查看 ...