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

js 禁止表单form提交的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 09:54:56
Original
1844 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:
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
Latest Issues
Where is js written?
From 1970-01-01 08:00:00
0
0
0
js file code not found
From 1970-01-01 08:00:00
0
0
0
js addClass not working
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template