<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用法的更多相关文章

  1. (转)jquery.validate.js 的 remote 后台验证

    之前已经有一篇关于jquery.validate.js验证的文章,还不太理解的可以先看看:jQuery Validate 表单验证(这篇文章只是介绍了一下如何实现前台验证,并没有涉及后台验证remot ...

  2. jquery.validate.js 表单验证简单用法

    引入jquery.validate.js插件以及Jquery,在最后加上这个插件的方法名来引用.$('form').validate(); <!DOCTYPE html PUBLIC " ...

  3. jquery validate.js表单验证的基本用法入门

    这里转载一篇前辈写的文章,在我自己的理解上修改了一下,仅作记录. 先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript&quo ...

  4. jquery.validate.js remote (php)

    网上的人不厚道呀 validate 这玩意的异步是 返回的 echo 'true'  或者 echo 'false';很少有人说呀~.~  转载了一篇原文: jquery.validate.js对于数 ...

  5. jquery.validate.js表单验证 jquery.validate.js的用法

    jquery.validate.js这个插件已经用了2年多了,是一个不可多得的表单验证最方便快捷的插件.基于jquery的小插件,基本小白一学就会上手,对于项目表单页面比较多,元素比较多的校验,该插件 ...

  6. jquery.validate.js使用说明——后台添加用户邮箱功能:非空、不能重复、格式正确

    重点内容为:  jQuery验证控件jquery.validate.js使用说明+中文API[http://www.tuicool.com/articles/iABvI3] 简单教程可以参考[jQue ...

  7. 表单验证插件之jquery.validate.js

    提到表单验证的插件,第一个想到的就是jquery.validate.js,所以小生想在这里稍微详细地说一下这款插件的具体使用方法,便于理解,我直接附上整段demo的代码(没怎么调样式,主要是看js): ...

  8. jQuery验证控件jquery.validate.js使用说明

    官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...

  9. jquery.validate.js插件使用

    jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...

随机推荐

  1. Jquery validate插件使用方法详解

    html: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Reg.aspx.c ...

  2. Kik CEO Ted Livingston发博称要成为西方的微信?

    加拿大手机聊天应用Kik是一款手机通信录的社交软件,和Snapchat.微信相似,上个月刚拿到3830万美元融资.近日,Kik CEO Ted Livingston在medium博客上发表了the r ...

  3. [Effective JavaScript 笔记] 第8条:尽量少用全局对象

    初学者容易使用全局变量的原因 创建全局变量毫不费力,不需要任何形式的声明(只要在非函数里用var 你就可以得到一个全局变量) 写得代码简单,不涉及到大的项目或配合(写hello world是不会有什么 ...

  4. 坚持不懈之linux haproxy 配置文件 详情

    ####################全局配置信息######################## #######参数是进程级的,通常和操作系统(OS)相关######### global maxc ...

  5. Decompiled .class file,bytecode version:51.0(Java 7) Source for 'Android API 23 Platform' not found

    今天在Android Studio中访问Java源码的时候,代码上方出现如下提示: 而且方法体中显示介样内容: throw new RuntimeException("Stub!" ...

  6. Group Shifted Strings

    Given a string, we can "shift" each of its letter to its successive letter, for example: & ...

  7. 3Sum & 4Sum

    3 Sum Given an array S of n integers, are there elements a, b, c in Ssuch that a + b + c = 0? Find a ...

  8. 玩转ubuntu FAQ

    一.用wubi安装ubuntu的时候自动重新下载 1.双击ubuntu.ios让windows加载这个镜像 2.断开网络 二.安装其他程序时提示Error: Dependency is not sat ...

  9. mysql工具

    MySQL工具汇总 收录了MySQL相关有用的工具.工具包含:性能测试,状态分析,SQL路由等方面 本文汇总了和MySQL运维开发相关的所有工具,并会持续更新 工具套件集 percona-toolki ...

  10. ini 文件操作记要(1): 使用 TIniFile

    ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Class ...