Skip to content

Instantly share code, notes, and snippets.

@hehongwei44
Created July 5, 2014 09:32
Show Gist options
  • Save hehongwei44/4db037bfc161a3e0f776 to your computer and use it in GitHub Desktop.
Save hehongwei44/4db037bfc161a3e0f776 to your computer and use it in GitHub Desktop.
判断输入的参数是否是国内合法的邮编地址
/**
*
* @descrition:判断输入的参数是否是国内合法的邮编地址(ps:国内不包含国外的邮编)
* @link: http://www.youbianku.com/%E9%A6%96%E9%A1%B5
* @param: str为待验证的邮编号码
* @return: true表示为合法的邮编号码
*
*/
var isPostcode = function(str) {
//国内邮编以0-8开头的6为数字
var pattern = /^[0-8]\d{5}$/;
return pattern.test(str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment