Home > Backend Development > PHP Tutorial > 十分简单的php验证

十分简单的php验证

WBOY
Release: 2016-06-13 12:48:02
Original
895 people have browsed it

非常简单的php验证.
请大神给段代码吧,我知道很简单,可是我试验很多方法,不是不跳转就是原地不动。怎么也搞不出来.
就是实现:输入框写邮政编码,然后验证如果是5个数字就跳转到下一页,不是5就停留在原页并且在输入框后面添加“邮政编码不对”.
感谢各位大神.


------解决方案--------------------
<script><br /> function iszipcode(object)<br /> {<br /> var s =document.getElementById(object.id).value; <br /> var pattern =/^[0-9]{6}$/;<br /> if(s!="")<br /> {<br /> if(!pattern.exec(s))<br /> {<br /> alert('请输入正确的邮政编码');<br /> object.value="";<br /> object.focus();<br /> }<br /> }<br /> }<br /> <br /> </script>

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