zoukankan      html  css  js  c++  java
  • button和sumbit提交表单的区别

          最新弄了个asp的软件,提交表单有点生疏了,下面总结了一下通过button和sumbit两种方式来提交表单:

          sumbit提交表单 

    View Code
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function checkForm()
    {
      
    if(document.form1.userName.value.length==0)
      {
         alert(
    "请输入用户名!");
         
    return false;
      }
      
    return true
      document.form1.submit(); 
    }
    </script>
    </head>

    <body>
    <form name="form1"  method="post" action="ygdacx.html" onsubmit="return checkForm()">
      
    <input type="text" name="userName" size="10" />
       
    <input type="submit" value="提 交" />
    </form>
    </body>
    </html>

     button提交表单 

    View Code
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    function checkForm()
    {
      
    if(document.form1.userName.value.length==0)
      {
         alert(
    "请输入用户名!");
         
    return false;
      }
      document.form1.action 
    ="ygdacx.html";   
      document.form1.submit(); 
    }
    </script>
    </head>

    <body>
    <form name="form1"  method="post">
      
    <input type="text" name="userName" size="10" />
       
    <!--<input type="submit" value="提 交" />  -->
       
    <input type="button" value="提 交"  onclick="checkForm()" />
    </form>
    </body>

    大家看出区别了吗,不说了..呵呵

    多思考,多创新,才是正道!
  • 相关阅读:
    立体匹配算法(转载)
    校招总结
    tcpip概述
    Matlab2014a 提示未找到支持的编译器或 SDK的解决方法
    CSS3 实现简单轮播图
    css3实现switch开关效果
    Sass的使用和基础语法
    Git的安装和使用记录
    jQuery淡入淡出效果轮播图
    JavaScript焦点轮播图
  • 原文地址:https://www.cnblogs.com/shuang121/p/2181656.html
Copyright © 2011-2022 走看看