目前,我使用的是http://jqueryvalidation.org/,我有这种表格
<form action="AddDefectToDatabaseServlet" method="post" id="myForm">
然后在我的js脚本中
$(document).ready(function() {
$('#myform').validate({ // initialize the plugin
rules: {
title: {
required: true
},
description: {
required: true
}
},
errorPlacement: function(){
return false;
},
submitHandler: function (form) { // for demo
alert('valid form submitted'); // for demo
return false; // for demo
}
});
});
但我的问题是,即使验证错误,它仍然会转到服务器端,对不起我是这个插件的新手,
答案 0 :(得分:0)
您缺少invalidHandler。
来自文档 - http://jqueryvalidation.org/validate
invalidHandler
Type: Function()
Callback for custom code when an invalid form is submitted. Called with an event object as the first argument, and the validator as the second.