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

十分简单的php验证

WBOY
WBOYOriginal
2016-06-13 12:48:02861browse

非常简单的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>

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