也许这个例子有帮助。
在您的代码中:
<!-- add the id attribute to your form, to get it with JS --><form id="f" name="f" action="${fn:escapeXml(form_url)}" method="POST"> ... <!-- add an input checkbox --> <input type="checkbox" id="terms" /> .... <!-- in your input button add onclick attribute calling the JS function --> <input id="proceed" onclick="doSubmit()" type="submit" value="${fn:escapeXml(submit_label)}" /> ...</form>这是您需要的JS函数:
function doSubmit() { var checkbox = document.getElementById("terms"); if (!checkbox.checked) { alert("error message here!"); return; } document.getElementById("f").submit();}希望能帮助到你。



