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 ...
随机推荐
- POJ 1191 棋盘分割
棋盘分割 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 11213 Accepted: 3951 Description 将一个 ...
- Linux下建立软链接
实例:ln -s /home/gamestat /gamestat Linux下的软链接类似于windows下的快捷方式 ln -s a b 中的 a 就是源文件,b是链接文件名,其作用是当进入 ...
- UItableView 编辑
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:( ...
- 极客教学:如何使用树莓派击落&劫持无人机
本教程的目的是帮助大家理解如何研究未受保护的无线通信的安全风险所在,同时我们希望大家不要对技术进行滥用.我们这里采用的例子是一个流行的无人机模型:Parrot AR.Drone 2.0. 四轴无人机能 ...
- tornado--之cookie自定义(还有session)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhAAAAHzCAIAAAD+WrNvAAAgAElEQVR4nOy993cTV7/vf/6qu865ob
- 利用zabbix监控某个目录大小
近期,因为JMS的消息堆积导致ApacheMQ频率故障(消息没有被消费掉,导致其数据库达到1.2G,JMS此时直接挂掉),很是郁闷!刚好自 己在研究zabbix.既然zabbix如此强大,那么它可以监 ...
- 如何判断CPU字节序之[Big-endian vs Little-endian]
[本文链接] http://www.cnblogs.com/hellogiser/p/big-endian-vs-little-endian.html [Big-endian vs Little-en ...
- poj1166
爆搜就可以过,不过我用了迭代加深. 注意每个操作最多进行4次 #include <cstdio> #include <cstdlib> using namespace std; ...
- iOS tableview 选中Cell后的背景颜色和文字颜色
做下记录,备忘 改文字颜色其实是UILabel的属性,改背景颜色是cell的属性,都和tableview无关. cell.textLabel.textColor = BAR_COLOR; cell.t ...
- sphinx 增量索引与主索引使用测试
2013年10月28日 15:01:16 首先对新增的商品建立增量索引,搜索时只使用增量索引: array (size=1) 0 => array (size=6) 'gid' => st ...