<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
<
head
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
/>
<
title
>jquery validate 插件实例01</
title
>
<
meta
name
=
"author"
content
=
"Administrator"
/>
<
link
rel
=
"stylesheet"
type
=
"text/css"
href
=
"js/css/screen.css"
/>
<
script
type
=
"text/javascript"
src
=
"js/jquery-1.9.0.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.validate.js"
></
script
>
<
script
type
=
"text/javascript"
>
$(function(){
$("#myform").validate({
rules:{
username:"required",
address:{
required:true,
minlength:3
},
age:"digits",
pwd:"required",
cpwd:{
equalTo:"#pwd"
}
},
messages:{
username:"用户名必须输入",
address:{
required:"用户地址必须输入",
minlength:"地址不能小于3位"
},
age:"年龄必须是整数",
pwd:"密码必须输入",
cpwd:"两次密码不一致"
}
});
});
</
script
>
</
head
>
<
body
>
<
form
id
=
"myform"
action
=
"#"
>
Username:<
input
type
=
"text"
id
=
"username"
name
=
"username"
/><
br
/>
Address:<
input
type
=
"text"
id
=
"address"
name
=
"address"
/><
br
/>
Age:<
input
type
=
"text"
id
=
"age"
name
=
"age"
/><
br
/>
password:<
input
type
=
"text"
id
=
"pwd"
name
=
"pwd"
/><
br
/>
confirm password:<
input
type
=
"text"
id
=
"cpwd"
name
=
"cpwd"
/><
br
/>
<
input
type
=
"submit"
/>
</
form
>
</
body
>
</
html
>