重点内容为:  jQuery验证控件jquery.validate.js使用说明+中文API【http://www.tuicool.com/articles/iABvI3】

简单教程可以参考【jQuery的validate插件使用整理(传智播客_王昭珽)】

(一)需求介绍

管理员后台添加用户时,邮箱需要满足需求有

(1)不能为空,因为要支持用户使用邮箱登陆

(2)不恩重复,因为要用户使用邮箱登陆所有重复会让使用户登陆报错

(3)格式正确

(二)效果

(三)编码

(1)jsp页面

说明:f:text是自定义标签

validate是一个基于Jquery的表单验证插件,利用他的remote可以用来自定义远程验证 JQuery validate插件Remote用法大全的相关资料(http://www.jb51.net/article/84220.htm) 关键是格式要正确:如   class里面的   email:{email:true},

 <td class="in-lab" width="15%">
<s:message code="user.email"/>:</td> <td class="in-ctt" width="35%" > <f:text
name="email"
value="${oprt=='edit' ? (bean.email) : ''}"
class="{
email:{email:true},
required:true,
remote:{url:'check_email.do',
type:'post',
data:{original:'${oprt=='edit' ? (bean.email) : ''}'}},
messages:{remote:'${emailExist}'}}" style="width:180px;"/>
</td>

jsp页面对user.email.exist的提示信息用变量emailExist进行了保存

 <c:set var="emailExist">
<s:message code="user.email.exist"/>
</c:set>

user.email.exist信息保存在配置文件中

 user.email.exist=\u7535\u5B50\u90AE\u7BB1\u5DF2\u5B58\u5728  //电子邮箱已存在

(2)controller层方法

     /**
* 检查邮箱是否存在
*
* @return
* @throws IOException
*/
@RequestMapping("check_email.do")
public void checkEmail(String email, String original, HttpServletResponse response) {
if (StringUtils.isBlank(email)) {
Servlets.writeHtml(response, "false");
return;
}
if (StringUtils.equals(email, original)) {
Servlets.writeHtml(response, "true");
return;
}
// 检查数据库是否重名
boolean exist = service.emailExist(email);
if (!exist) {
Servlets.writeHtml(response, "true");
} else {
Servlets.writeHtml(response, "false");
}
}

jquery.validate.js使用说明——后台添加用户邮箱功能:非空、不能重复、格式正确的更多相关文章

  1. (转)jQuery验证控件jquery.validate.js使用说明+中文API

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

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

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

  3. jQuery验证控件jquery.validate.js使用说明+中文API(转)

    一导入js库<script src="../js/jquery.js" type="text/javascript"></script> ...

  4. jQuery验证控件jquery.validate.js使用说明+中文API

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

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

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

  6. jquery.validate.js插件使用

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

  7. jQuery插件之验证控件jquery.validate.js

    今天学习一下jQuery.Validate插件,为便于日后翻阅查看和广大博客园园友共享,特记于此. 本博客转载自:jQuery Validate jQuery Validate 插件为表单提供了强大的 ...

  8. jquery.validate.js表单验证

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  9. jquery.validate.js 一个jQuery验证格式控件

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

随机推荐

  1. 随机Loading

    using UnityEngine; using System.Collections; public class Loading : MonoBehaviour { public bool m_Is ...

  2. Unity3D研究院之自制批量关联材质与贴图插件

    原地址:http://www.xuanyusong.com/archives/2314 美术做过的模型导出fbx,美术把Fbx和贴图文件给了程序,程序把Fbx导入工程可能会出现贴图和材质没有关联上的问 ...

  3. c++中的srand()和rand() 转载 自:http://blog.sina.com.cn/s/blog_624c2c4001012f67.html

    今天看了同事写的小程序,发现了其中出现了srand()和rand()这两个我以前没有用过的函数,当然从名字可以看出肯定能随机数有关,于是网查资料知这两个函数配合一起使用来产生随机数的,哈哈,又长知识了 ...

  4. windows 程序的本体与操作系统之间的关系

    WinMain(hInst,hPrev,……) { MSG msg; RegisterClass(……); CreateWindow(……); ShowWindow(……); UpdateWindow ...

  5. [BZOJ1477]青蛙的约会

    [BZOJ1477]青蛙的约会 试题描述 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它们出发之前忘 ...

  6. 题目1006:ZOJ问题

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:13212 解决:2214 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC. 是否AC的规则如下:1. ...

  7. 【VirtualBox】VirtualBox的桥接网络模式,为啥网络不稳定?

    网桥模式访问外网非常慢,经常卡死,ping时断时续 七搞八搞,反复重启了几次 TMD  就好了,也不知道什么情况,VirtualBox还是不太好使啊..... 网桥模式 设置 如下: 参考资料: ht ...

  8. spring事物传播属性

    PROPAGATION_REQUIRED Support a current transaction; create a new one if none exists.  支持一个当前事务;如果不存在 ...

  9. Python之property装饰器

    参考: http://www.cnblogs.com/lovemo1314/archive/2011/05/03/2035600.html http://joy2everyone.iteye.com/ ...

  10. explict关键字

    [本文链接] http://www.cnblogs.com/hellogiser/p/explict.html [分析] explicit 只对构造函数起作用,用来抑制隐式转换. Suppose yo ...