xjinza

一、用input type="submit"方式提交表单

该方法可以触发onsubmit事件,但无法通过onclick进行校验,也就是说formSubmit函数里面的return false是无效的。所以只能通过onsubmit来进行表单校验。
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
 <script type="text/javascript"> function formSubmit() { 
//return false; 不能在onclick事件里面进行表单校验,只能通过onsubmit。
           
        }
    </script>
</head>

<body>

<form id="myForm" action="http://www.baidu.com" method="get" onsubmit="return false;">
    姓名:<input type="text" name="name" size="20"><br />

    <input type="submit" onclick="formSubmit()" value="提交">
</form>
</body>

</html>

分类:

技术点:

相关文章:

  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-12-12
  • 2021-12-31
  • 2021-04-11
猜你喜欢
  • 2021-11-27
  • 2021-09-13
  • 2022-12-23
  • 2021-07-25
  • 2021-11-17
  • 2021-12-02
  • 2022-01-24
相关资源
相似解决方案