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>
  • 相关阅读:
    IIS日志-网站运维的好帮手
    精选7款绚丽的HTML5和jQuery图片动画特效
    不错的东西
    【今日推荐】10大流行的 Metro UI 风格的 Bootstrap 主题和模板
    跨域使用jsonp 获取天气预报
    《JavaScript权威指南》读书笔记(三)
    css背景定位
    网页加载速度的优化
    CSS书写顺序
    《JavaScript权威指南》读书笔记(二)
  • 原文地址:https://www.cnblogs.com/zizaifeihuaqingsimeng/p/5947444.html
Copyright © 2011-2022 走看看