在提交表单前如果需要对表单内容进行统一验证,就可以使用οnsubmit="return check()",只有当check()方法返回true,表单才会提交
<form action="<%=request.getContextPath()%>/User/register" method="POST" οnsubmit="return check()">
用户名:<input id="userName" name="userName" >
密码:<input id="password" name="password">
<button type="submit" >提交</button>
<div id="error">${error}</div>
</form>