Home  >  Article  >  Web Front-end  >  js 禁止表单form提交的方法

js 禁止表单form提交的方法

WBOY
WBOYOriginal
2016-06-01 09:54:561762browse

代码如下,主要使用到preventDefault方法。

<code>
<title>js 禁用表单form提交的方法</title>

<script type="text/javascript" src="/Public/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("form").submit(function(e){
    e.preventDefault();
    alert("form已经禁止提交");
  });
});
</script>


<form name="input" action="123.php" method="post">
email: 
<input type="text" name="email" value="1233@q.com" size="20">
<br>address: 
<input type="text" name="address" value="dsf" size="20">
<br>
<input type="submit" value="Submit">
</form> 

</code>

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn