<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'validate.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
</head>
<script type="text/javascript">
//Jquery代码
$(document).ready(function(){
//拿到form调用验证方法
$("empForm").validate({
rules:{
name: "required"
},
messages:{
name: "姓名不能为空"
}
});
});
</script>
<body>
<form action="" name="empForm" id="empForm" method="post">
Name:<input name="name" id="name"/><br/>
Password:<input type="password" name="password" id="password"/>
<input type="submit" value="User" name="submit" id="submit"/>
</form>
</body>
</html>
jquery?验证框架?jsp
------解决方案--------------------
jQuery 导入路径对不
------解决方案--------------------
$("empForm") 改成 $("#empForm") 或者$("form[name='empForm']")
------解决方案--------------------
+1