我想验证我的表单提交使用jqueryvalidation.js。 像jQuery验证需要不工作,我想知道为什么
HTTP Status 400 -
type Status report
message
description The request sent by the client was syntactically incorrect.
浏览器响应我用这个代码,但没有验证工作
<script type="text/javascript" src = "${contextPath }/static/js/jquery-migrate-1.4.1.min.js"></script>
<script type="text/javascript">
window.jQuery || document.write("<script src='${contextPath}/static/ace_admin1.3.1/assets/js/jquery.min.js'>"+"<"+"/script>");
</script>
<script type="text/javascript" src = "${contextPath }/static/js/jquery.validate.min.js"></script>
<script type="text/javascript">
$.validator.setDefaults({
submitHandler: function() {
alert("sumbit");
}
});
$(function() {
$("#subjectForm").validate({
rules: {
name : {
required: true,
},
testCount : {
required: true,
},
totalTime : {
required: true,
},
totalScore : {
required: true,
}
},
});
});
</script>
</head>
<body>
<form id="subjectForm " action="${contextPath }/teacher/testAddSubject" method="POST">
<p>add</p>
<p><label>subjectName</label><input name = "name" type ="text"/></p>
<p><label>Description</label><input name = "description" type ="text"/></p>
<p><label>number</label><input name = "testCount" type ="text"/></p>
<p><label>time</label><input name = "totalTime" type ="text"/></p>
<p><label>grade</label><input name = "totalScore" type ="text" /></p>
<button type="submit">submit</button>
</form>
</body>
</html>
我不知道什么地方出错,请帮忙me.it关于jQuery的版本和jQuery验证版本?
首先:'$ {contextPath}'不是您的实际代码...... ***在浏览器中呈现的代码是JavaScript正在使用的代码。其次,你的问题与JavaScript无关。下面是状态码400的定义:*“由于格式错误,服务器无法理解请求,客户端不应该不加修改地重复请求。”* – Sparky