Created
April 25, 2013 15:24
-
-
Save oliveagle/5460571 to your computer and use it in GitHub Desktop.
javascript: validate chinese zipcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isPostalCode(object) { | |
| //校验(国内)邮政编码 | |
| var s = document.getElementById(object.id).value; | |
| var pattern = /^[0-9]{6}$/; | |
| if (s !== "") { | |
| if (!pattern.exec(s)) { | |
| alert('请输入正确的邮政编码'); | |
| object.value = ""; | |
| object.focus(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment