jquery.validate.js使用说明——后台添加用户邮箱功能:非空、不能重复、格式正确
重点内容为: 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使用说明——后台添加用户邮箱功能:非空、不能重复、格式正确的更多相关文章
- (转)jQuery验证控件jquery.validate.js使用说明+中文API
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- jQuery验证控件jquery.validate.js使用说明
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- jQuery验证控件jquery.validate.js使用说明+中文API(转)
一导入js库<script src="../js/jquery.js" type="text/javascript"></script> ...
- jQuery验证控件jquery.validate.js使用说明+中文API
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 学习 ...
- (转)jquery.validate.js 的 remote 后台验证
之前已经有一篇关于jquery.validate.js验证的文章,还不太理解的可以先看看:jQuery Validate 表单验证(这篇文章只是介绍了一下如何实现前台验证,并没有涉及后台验证remot ...
- jquery.validate.js插件使用
jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...
- jQuery插件之验证控件jquery.validate.js
今天学习一下jQuery.Validate插件,为便于日后翻阅查看和广大博客园园友共享,特记于此. 本博客转载自:jQuery Validate jQuery Validate 插件为表单提供了强大的 ...
- jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- jquery.validate.js 一个jQuery验证格式控件
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
随机推荐
- 2013 ACM/ICPC Asia Regional Chengdu Online 1004 Minimum palindrome
Minimum palindrome Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- Mysql_以案例为基准之查询
查询数据操作
- python-twisted
环境:win7 64位,python 2.7.3 安装: http://twistedmatrix.com/Releases/Twisted/14.0/Twisted-14.0.0.win-amd64 ...
- HXOI 2014 PSet 4 Day 1 一模04日1 题解
1. 最小花费(money.pas/c/cpp) 问题描述 在n个人中,某些人的银行账号之间可以互相转账.这些人之间转账的手续费各不相同.给定这些人之间转账时需要从转账金额里扣除百分之几的手续费,请问 ...
- Firefox上Web开发工具库一览
Firefox的目标之一就是尽可能地使web开发者的生活更简单高效,并通过提供工具和具有很强扩展性的浏览器使人们创造出神奇的东西.使web开发者使用Firefox的时候,浏览器可以提供大量开发工具和选 ...
- 明白python文件如何组织,理解建立源文件
在Python 中引用是非常简单的事情,这里需要清楚三个概念就可以了包.模块.类.类这个就不用说了. 模块对应的是一个.py 文件,那么module_name 就是这个文件去掉.py 之后的文件名,p ...
- windows下bat批处理实现守护进程
本文转自网络,由于找不到原作者,因而无法知道出处.如果有幸让原作者看到,请联系我加上.先转载至此. 最近几天加班加疯掉了,天天晚上没法睡.开发部的一个核心程序总是会自己宕机,然后需要手工去起,而这个服 ...
- 用cocos2dx实现模态对话框
ui部分使用了cocoStudio,注意这里没有实现怎么屏蔽其他的输入事件,其他的文档已经太多了,我这里使用的cocoStudio的控件自己的特性. 这里强烈推荐一下cocoStudio,虽然现在还有 ...
- oracle通过plsql导入dmp数据文件
首先安装Oracle,新建一个空的数据库mydb 从开始菜单运行cmd控制台:sqlplus "用户名/密码@数据库名 as sysdba"//例如sqlplus sys/admi ...
- July 15th, Week 29th Friday, 2016
A book is a gift that you can open again and again. 书是你可以一次又一次打开的礼物. Some gifts are born with you, a ...