表单怎么进行验证?_html/css_WEB-ITnose

WBOY
Release: 2016-06-21 09:40:37
Original
906 people have browsed it

 <script type="text/javascript">             function checkNum() {                 return;             }  <form action="?step=2" method="post"> <button type="submit" class="mt15 redbtn" onclick="checkNum();">提交退换货申请     </button> </form>	
Copy after login

写成上面这样不起作用,照样提交到服务器

写成下面这样就有作用
 <form action="?step=2" method="post"> <button type="submit" class="mt15 redbtn" onclick="javascript:return false;">提交退换货申请     </button> </form>	
Copy after login

咋办呢?我要在checkNum()方法里面进行验证的


回复讨论(解决方案)

return confirm(这里面写的你函数);

因为你的按钮类型是submit。使用button就不会出现这个问题。另外你的<script>括起来啊。 </script>

不能用onclick,应该用onSubmit

不然人家用键盘怎么办?

另外应该是return checkNum();

谢谢大家,3楼说的对

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