Skip to content

Instantly share code, notes, and snippets.

@oliveagle
Created April 25, 2013 15:24
Show Gist options
  • Select an option

  • Save oliveagle/5460571 to your computer and use it in GitHub Desktop.

Select an option

Save oliveagle/5460571 to your computer and use it in GitHub Desktop.
javascript: validate chinese zipcode
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