jQuery 验证要求无效,我想知道为什么
jQuery Validate required not working, I want know why
我正在尝试使用 jqueryvalidation.js 验证我的表单提交。
这样的浏览器响应
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验证版本?
删除...
末尾多余的 space
id="subjectForm "
它正在破坏你的 JavaScript。损坏 JavaScript,jQuery Validate 将不会初始化。
(您还需要包括 jQuery 迁移 AFTER jQuery)
就你的状态码400而言:
The request sent by the client was syntactically incorrect.
这与 jQuery 验证插件完全无关。
400 Bad Request: The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
所以我建议您检查浏览器中的 rendered DOM 并确保每个服务器请求 (URL) 格式正确。另外,在 ${contextPath}/teacher/testAddSubject
查看您的服务器端脚本并确保它没有损坏。
我正在尝试使用 jqueryvalidation.js 验证我的表单提交。 这样的浏览器响应
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验证版本?
删除...
末尾多余的 spaceid="subjectForm "
它正在破坏你的 JavaScript。损坏 JavaScript,jQuery Validate 将不会初始化。
(您还需要包括 jQuery 迁移 AFTER jQuery)
就你的状态码400而言:
The request sent by the client was syntactically incorrect.
这与 jQuery 验证插件完全无关。
400 Bad Request: The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.
所以我建议您检查浏览器中的 rendered DOM 并确保每个服务器请求 (URL) 格式正确。另外,在 ${contextPath}/teacher/testAddSubject
查看您的服务器端脚本并确保它没有损坏。