重点内容为:  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. Ubuntu nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

    在Ubuntu 12中启动刚安装好的Nginx,报错: nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) 原因如下: ...

  2. [LA4108]SKYLINE

    [LA4108]SKYLINE 试题描述 The skyline of Singapore as viewed from the Marina Promenade (shown on the left ...

  3. &&队友最近一周水水

    100130 练习5 5 hr ago 15.2 days Private qwerqqq 100093 DP2 16 hr ago 50.2 days Private qwerqqq 100092 ...

  4. linux 系统下查看raid信息,以及磁盘信息

    有时想知道服务器上有几块磁盘,如果没有做raid,则可以简单使用fdisk -l  就可以看到. 但是做了raid呢,这样就看不出来了.那么如何查看服务器上做了raid? 软件raid:只能通过Lin ...

  5. Ninject学习笔记<二>

    本文转载自kuangkro 如果给您带来不便请联系博主 一.控制反转和依赖注入 Ninject是一个轻量级的基于.Net平台的依赖注入(IOC)框架.所谓的IOC,即控制反转(Inversion of ...

  6. Maximum Product Subarray

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  7. Linux下配置Tomcat服务器

    Linux下配置Tomcat服务器和Windows下其实差不多,可以去官网下载安装包释放或者在线下载,只是当时下载的windows.zip文件,现在下载.tar.gz格式的即可,下面使用命令行的方式安 ...

  8. angularjs 指令(directive)详解(2)

    原文地址 上一篇我们说到了transclude,那么,我们现在继续讲解之后的内容. 9.scope 可选参数,默认值为false.取值: false - 在这个directive里不会创建新的scop ...

  9. css3学习总结6--CSS3字体

    使用自己需要的字体 在新的 @font-face 规则中,您必须首先定义字体的名称(比如 myFirstFont),然后指向该字体文件. 如需为 HTML 元素使用字体,请通过 font-family ...

  10. Solr的函数查询(FunctionQuery)

    作用 通过函数查询让我们可以利用 numeric域的值或者与域相关的的某个特定的值的函数,来对文档进行评分. 如何使用 这里主要有两种方法可以使用函数查询,这两种方法都是通过solr http 接口的 ...