zoukankan      html  css  js  c++  java
  • js验证表单并提交

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
        <head>
            <title></title>
            <meta http-equiv="content-type" content="text/html;charset=utf-8">
            <meta name="keywords" content="html,javascript,css">
            <script type="text/javascript">
                function denglu()
                {
                    var userno=document.getElementById("userno").value;
                    var userpwd=document.getElementById("userpwd").value;
                    if(userno=="")
                    {
                        return false;
                    }
                    else if(userpwd=="")
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
            </script>
        </head>
        <body>
            <form id="form1" action="test_login_handle.php" method="post">
                <div>账号:<input type="text" id="userno" placeholder="输入用户账号" /></div>
                <div>密码:<input type="password" id="userpwd" placeholder="输入用户密码" /></div>
                <div><input type="submit" value="登录" onclick="return denglu()" /></div>
            </form>
        </body>
    </html>
    
    
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
        <head>
            <title></title>
            <meta http-equiv="content-type" content="text/html;charset=utf-8">
            <meta name="keywords" content="html,javascript,css">
            <script type="text/javascript">
                function denglu()
                {
                    var userno=document.getElementById("userno").value;
                    var userpwd=document.getElementById("userpwd").value;
                    if(userno=="")
                    {
                        return false;
                    }
                    else if(userpwd=="")
                    {
                        return false;
                    }
                    else
                    {
                        return true;
                    }
                }
            </script>
        </head>
        <body>
            <form id="form1" action="test_login_handle.php" method="post" onsubmit="return denglu()">
                <div>账号:<input type="text" id="userno" placeholder="输入用户账号" /></div>
                <div>密码:<input type="password" id="userpwd" placeholder="输入用户密码" /></div>
                <div><input type="submit" value="登录" /></div>
            </form>
        </body>
    </html>
    
    
    
    
    <<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
        <head>
            <title></title>
            <meta http-equiv="content-type" content="text/html;charset=utf-8">
            <meta name="keywords" content="html,javascript,css">
            <script type="text/javascript">
                function denglu()
                {
                    var userno=document.getElementById("userno").value;
                    var userpwd=document.getElementById("userpwd").value;
                    if(userno=="")
                    {
                        return false;
                    }
                    else if(userpwd=="")
                    {
                        return false;
                    }
                    else
                    {
                        document.form1.submit();
                    }
                }
            </script>
        </head>
        <body>
            <form id="form1" action="test_login_handle.php" method="post">
                <div>账号:<input type="text" id="userno" placeholder="输入用户账号" /></div>
                <div>密码:<input type="password" id="userpwd" placeholder="输入用户密码" /></div>
                <div><input type="button" value="登录" onclick="denglu()" /></div>
            </form>
        </body>
    </html>
  • 相关阅读:
    Linux-线程同步(day14续)
    Linux之线程(day14)
    Linux-网络编程-UDP网络编程(day13续2)
    ES6 模块加载
    let与var声明区别
    vue 常用指令v-if v-else v-show v-for
    动态路由的意义,以及路由重定向
    前端路由的理解
    socpe 与 包的引入
    VUE 组件注册(全局、局部)
  • 原文地址:https://www.cnblogs.com/zizaifeihuaqingsimeng/p/5947444.html
Copyright © 2011-2022 走看看