重点内容为:  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. 【初级为题,大神绕道】The app icon set named "AppIcon" did not have any applicable content 错误#解决方案#

    The app icon set named "AppIcon" did not have any applicable content 错误,怎样解决   按照您的错误提示您应该 ...

  2. Robot Motion(imitate)

    Robot Motion Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11065   Accepted: 5378 Des ...

  3. redis和memcached比较

    1.Memcached采用客户端-服务器的架构,服务器维护了一个键-值关系的数据表,服务器之间相互独立,互相之间不共享数据也不做任何通讯操作.客户端需要知道所有的服务器,并自行负责管理数据在各个服务器 ...

  4. HLG2035广搜

    Diablo Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 42(21 users) Total Accepted: 23(20 us ...

  5. #!/bin/bash

    #!/bin/bash是指此脚本使用/bin/bash来解释执行. 其中,#!是一个特殊的表示符,其后,跟着解释此脚本的shell路径. bash只是shell的一种,还有很多其它shell,如:sh ...

  6. VMware Snapshot 工作原理

    VMware中的快照是对VMDK在某个时间点的“拷贝”,这个“拷贝”并不是对VMDK文件的复制,而是保持磁盘文件和系统内存在该时间点的状态,以便在出现故障后虚拟机能够恢复到该时间点.如果对某个虚拟机创 ...

  7. Find Leaves of Binary Tree

    Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves ...

  8. 【leetcode】Palindrome Partitioning

    Palindrome Partitioning Given a string s, partition s such that every substring of the partition is ...

  9. 【UGUI】Canvas和Rect Transform

    Canvas 1.所有的UI元件都需要放在Canvas里 2.UI元件的绘制顺序,与在 Hierarchy的顺序相同,在上面的元素会先被绘制,位于后续绘制元素的下面 3.可以选择3种不同的渲染模式: ...

  10. poj 1328

    http://poj.org/problem?id=1328 题意:题目大概意思就是有一群孤岛,想要用雷达来监视这些岛屿,但雷达的范围是有限的,所以需要多个雷达,题目就是要你解决最少需要几个雷达,注意 ...