我有这个jsp页面-
<%@page import="java.text.Normalizer.Form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body>
<legend>Create new customer</legend>
<%!
boolean checkForm(Form theForm)
{
// some checks on "theForm" ..
return false ;
}
%>
<form action="CreateCustomerServlet" method="GET" onsubmit=<%=checkForm() %>>
// form's fields ..
<input type="submit" value="Create customer" />
</form>
</fieldset>
</body>
</html>
我想要做的是,当按下它时,submit它会转到checkForm函数并检查表单,只有当它checkForm返回true时,它才会进入CreateCustomerServletservlet。
但是当我在服务器上运行这个页面并按下submit按钮时,我看到它被忽略checkForm并直接转到CreateCustomerServletservlet 。
我知道用 javascript 来做这件事很容易.. 但我想用 java 函数来做。