xuyan5971
BlogJava
首页
新随笔
联系
聚合
管理
数据加载中……
jquery validation
1
<%
@page contentType
=
"
text/html; charset=GBK
"
%>
2
<%
@taglib uri
=
"
http://java.sun.com/jsp/jstl/core
"
prefix
=
"
c
"
%>
3
<%
@ taglib uri
=
"
http://java.sun.com/jsp/jstl/fmt
"
prefix
=
"
fmt
"
%>
4
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
5
<
html
xmlns
="http://www.w3.org/1999/xhtml"
lang
="GBK"
xml:lang
="GBK"
>
6
<
head
>
7
<
meta
http-equiv
="Pragma"
content
="no-cache"
/>
8
<
meta
http-equiv
="Cache-Control"
content
="no-cache"
/>
9
<
meta
http-equiv
="Expires"
content
="0"
/>
10
<
link
type
="text/css"
title
="www"
rel
="stylesheet"
media
="all"
href
="<c:url value="
/theme/1/control/control.css"
/>
" />
11
<
title
>
jQuery之验证插件
</
title
>
12
<
style
type
='text/css'
>
13
*
{
}
{
font-family
:
Verdana
;
font-size
:
96%
;
}
14
label.error
{
}
{
float
:
none
;
color
:
red
;
padding-left
:
.5em
;
vertical-align
:
top
;
}
15
p
{
}
{
clear
:
both
;
}
16
.submit
{
}
{
margin-left
:
12em
;
}
17
em
{
}
{
font-weight
:
bold
;
vertical-align
:
top
;
}
18
</
style
>
19
<
script
type
='text/javascript'
src
='<c:url
value
="/js/jquery-1.3.2.js"
/>
'
>
</
script
>
20
<
script
type
='text/javascript'
src
='<c:url
value
="/js/jquery.validate.js"
/>
'
>
</
script
>
21
<
script
type
='text/javascript'
>
22
$(document).ready(
function
()
{
23
$('#commentForm').validate(
{
24
rules:
{
25
username:
{
26
required:
true
,
27
minlength:
1
,
28
formula:
"
7+9
"
29
}
,
30
email:
{
31
required:
true
,
32
email:
true
33
}
,
34
url:
"
url
"
,
35
comment:
"
required
"
,
36
coco:
{formula:
"
7+9
"
}
,
37
valcode:
{formula:
"
7+9
"
}
38
}
,
39
messages:
{
40
//
为name为email的控件的required()和email()验证方法设置验证失败的消息内容
41
email:
{required:
"
需要输入电子邮箱
"
, email:
"
电子邮箱格式不正确
"
}
42
}
43
}
)
44
}
);
45
46
$.validator.addMethod(
47
"
formula
"
,
//
验证方法的名称
48
function
(value,element,param)
{
//
验证规则
49
return
value
==
eval(param);
50
}
,
51
'请输入正确的结果'
//
提示验证信息
52
);
53
</
script
>
54
</
head
>
55
56
<
body
>
57
<
form
class
='cmxform'
id
='commentForm'
method
='post'
action
='#'
>
58
<
fieldset
>
59
<
legend
>
一个简单的带有提示的评论例子
</
legend
>
60
<
p
>
61
<
label
for
='cusername'
>
姓名
</
label
><
em
>
*
</
em
>
62
<
input
id
='cusername'
name
='username'
size
='25'
/>
63
</
p
>
64
<
p
>
65
<
label
for
='cemail'
>
电子邮件
</
label
><
em
>
*
</
em
>
66
<
input
id
='cemail'
name
='email'
size
='25'
/>
67
</
p
>
68
<
p
>
69
<
label
for
='curl'
>
网址
</
label
><
em
>
*
</
em
>
70
<
input
id
='curl'
name
='url'
size
='25'
value
=''
/>
71
</
p
>
72
<
p
>
73
<
label
for
='cverify'
>
7+9=
</
label
><
em
>
*
</
em
>
74
<
input
id
='cverify'
name
='coco'
size
='25'
value
=''
/>
75
</
p
>
76
<
p
>
77
<
label
for
='cvalcode'
>
验证码
</
label
>
78
<
input
id
='cvalcode'
name
='valcode'
size
='25'
value
=''
/>
=7+9
79
</
p
>
80
<
p
>
81
<
label
for
='ccomment'
>
你的评论
</
label
><
em
>
*
</
em
>
82
<
textarea
id
='ccomment'
name
='comment'
cols
='25'
></
textarea
>
83
</
p
>
84
<
p
>
85
<
input
class
='submit'
type
='submit'
value
='提交'
>
86
</
p
>
87
</
fieldset
>
88
</
form
>
89
</
body
>
90
</
html
>
91
92
93
94
posted on 2009-10-15 13:37
R99
阅读(399)
评论(0)
编辑
收藏
新用户注册
刷新评论列表
只有注册用户
登录
后才能发表评论。
网站导航:
博客园
IT新闻
Chat2DB
C++博客
博问
管理
<
2009年10月
>
日
一
二
三
四
五
六
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
统计
随笔 - 16
文章 - 0
评论 - 6
引用 - 0
常用链接
我的随笔
我的评论
我的参与
最新评论
留言簿
给我留言
查看公开留言
查看私人留言
随笔分类
Lucene(2)
(rss)
随笔档案
2009年10月 (3)
2009年9月 (2)
2009年8月 (4)
2009年6月 (6)
搜索
最新评论
1. re: js 字符串的字符长度。(用于验证input长度,中文算两个字符)
评论内容较长,点击标题查看
--11111
2. re: js 字符串的字符长度。(用于验证input长度,中文算两个字符)[未登录]
jhgfds
--hh
3. re: js 字符串的字符长度。(用于验证input长度,中文算两个字符)
不错
--sss
4. re: js 字符串的字符长度。(用于验证input长度,中文算两个字符)[未登录]
</div>
--@
5. re: js 字符串的字符长度。(用于验证input长度,中文算两个字符)[未登录]
评论内容较长,点击标题查看
--@
阅读排行榜
1. js 字符串的字符长度。(用于验证input长度,中文算两个字符)(4527)
2. ajax回调函数调用多个参数。 循环调用。(1475)
3. lucence_对文件建立索引(925)
4. lucene_根据索引搜索文件(476)
5. [jQuery]animate(滑块滑动)(436)
评论排行榜
1. js 字符串的字符长度。(用于验证input长度,中文算两个字符)(6)
2. 动态改变onclick 所调的函数。(0)
3. jquery validation(0)
4. [jQuery]animate(滑块滑动)(0)
5. jquery学习笔记(0)