<%@ page language="java" pageEncoding="gbk"%>
<html>
<head>
<title>jqueryValidateDemo</title>
<script type="text/javascript" src="https://www.jb51.net/js/jquery.js"></script>
<script type="text/javascript" src="https://www.jb51.net/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="" method="post">
<table>
<tr>
<td>登录名</td>
<td><input type="text"/></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="注册"/></td>
</tr>
</table>
</form>
</body>
</html>
jquery 表单进行客户端验证demo
内容版权声明:除非注明,否则皆为本站原创文章。