admin管理员组文章数量:1321999
I have jsp page -
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ".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>
When I run on server this page and press on the submit
button I see that it ignore checkForm
and don't enter him , and directly go to CreateCustomerServlet
.
My goals is that when press on submit
it go to checkForm
and if checkForm
returns true
only then it will go to CreateCustomerServlet
. what I have to change in order to get this goal ?
I have jsp page -
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3/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>
When I run on server this page and press on the submit
button I see that it ignore checkForm
and don't enter him , and directly go to CreateCustomerServlet
.
My goals is that when press on submit
it go to checkForm
and if checkForm
returns true
only then it will go to CreateCustomerServlet
. what I have to change in order to get this goal ?
- I wanted to know.. I have written same code in jsp but in wele.jsp... but it's not working there, can you please make me know why? – Pallav Raj Commented Jan 14, 2015 at 17:49
3 Answers
Reset to default 3Try
onsubmit="return checkForm();"
You should replace
onsubmit="checkForm"
By
onsubmit="return checkForm();"
You should use
onsubmit="return checkForm();"
because only when false
is returned from onSubmit
will it be stopped , or else it will continue submitting the form.
本文标签: javascript function in jsp pageStack Overflow
版权声明:本文标题:javascript function in jsp page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742115982a2421469.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论