<!-- validate Scripts -->
<script src="${ctx}/plugins/jquery-validation/1.11.1/jquery.validate.min.js" type="text/javascript"></script>
<script src="${ctx}/plugins/jquery-validation/1.11.1/messages_bs_zh.js" type="text/javascript"></script>
在非submit 的方法中使用验证要加入以下代码
if (! $("#stockTakeItemForm").valid()) {
return;
}
--------------------------------------------------------------------
$("#stockInForm").validate({
<%--rules: {--%>
<%--<%–orderNo: {–%>--%>
<%--<%–remote: "${ctx}/storage/stockIn/findByOrderNo?oldOrderNo=" + encodeURIComponent('${stockIn.orderNo}')–%>--%>
<%--<%–}–%>--%>
<%--//roleList:"required"--%>
<%--},--%>
<%--messages: {--%>
<%--orderNo: {--%>
<%--remote: "入库单号已存在"--%>
<%--}--%>
<%--},--%>
errorContainer: "#messageBox",
errorPlacement: function (error, element) {
if (element.is(":checkbox"))
error.appendTo(element.parent().next());
else
error.insertAfter(element);
}
});
---------------------------------------------------
form的
<form class="form-horizontal form-label-left" novalidate id="stockTakeItemForm">
--------------------------------------------------------
错误提示:
<div id="messageBox" class="alert alert-error input-large controls" style="display:none">输入有误,请先更正。</div>
----------------------------------