jQuery控制表单提交

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery阻止表单提交.html</title>
    <script type="text/javascript" src="../js2/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#form").submit(function () {
                // if("验证通过"){
                //     return true;
                // }else{
                //     //验证失败
                //     return false;
                // }
                //window.location.href = "index.jsp";

            })
        })
    </script>
</head>
<body>

<form action="postServlet5" method="post" id="form">
    用户名:<input  type="text" name="username" id="username"/><br>
    密码:<input type="password" name="password" id="password"><br>
    <input type="submit" value="submit"/>
</form>

</body>
</html>

猜你喜欢

转载自blog.csdn.net/lidongkui123/article/details/80346999
今日推荐