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

js 禁止表单form提交的方法

WBOY
Release: 2016-06-01 09:54:56
Original
1787 people have browsed it

代码如下,主要使用到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>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template