【发布时间】:2012-08-01 07:44:46
【问题描述】:
我有 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。为了实现这个目标,我必须做出哪些改变?
【问题讨论】:
-
我想知道..我在jsp中写过同样的代码,但是在welcome.jsp中...但是它在那里不起作用,你能告诉我为什么吗?
标签: javascript jsp servlets forms onsubmit