我有jsp页面-
<!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>
<script Language="JavaScript">
function checkForm() {
alert("YOU ARE IN checkForm FUNCTION !");
return (false);
}
</script>
<form action="CreateCustomerServlet" method="GET" onsubmit="checkForm">
// form fields ...
<input type="submit" value="Create customer" />
</form>
</body>
</html>
当我在服务器上运行此页面并按下submit按钮时,我看到它忽略checkForm并且不输入他,然后直接转到CreateCustomerServlet。
我的目标是,当按下submit它时checkForm,如果只有checkForm返回true,它就会去CreateCustomerServlet 。为了达到这个目标,我必须改变什么?