jsp页面中的javascript函数 [英] javascript function in jsp page

查看:143
本文介绍了jsp页面中的javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有jsp页面 -

I have jsp page -

<!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>

当我在服务器上运行此页面并按下提交按钮我看到它忽略了 checkForm 并且没有输入他,直接转到 CreateCustomerServlet

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 .

我的目标是当按提交时,它会转到 checkForm 如果 checkForm 返回 true ,那么它将转到 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 ?

推荐答案

试试

onsubmit="return checkForm();"

这篇关于jsp页面中的javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆