jquery 表单进行客户端验证demo
下面图老师小编要跟大家分享jquery 表单进行客户端验证demo,简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!
%@ page language="java" pageEncoding="gbk"%
html
head
titlejqueryValidateDemo/title
script type="text/javascript" src="js/jquery.js"/script
script type="text/javascript" src="js/jquery.validate.js"/script
script type="text/javascript"
$(function() {
$("#login").validate({
rules:{
name:{
required:true
},
password:{
required:true,
minlength:4
}
},
messages:{
name:{
required:"此项为必填项"
},
password:{
required:"此项为必填项",
minlength:"密码长度至少为4个字符"
}
}
})
});
/script
/head
body
form action="" id="login" method="post"
table align="center" border="1"
tr
td登录名/td
tdinput type="text" id="name" name="name"//td
/tr
tr
td密码/td
tdinput type="password" id="password" name="password"//td
/tr
tr
td align="center" colspan="2"input type="submit" value="注册"//td
/tr
/table
/form
/body
/html