常用正则
// 身份证验证
//身份证正则表达式(15位)
isIDCard1=/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
//身份证正则表达式(18位)
isIDCard2=/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{4}$/;
// 护照验证
jQuery.validator.addMethod("isPassport", function(value, element, type) { if ($(type).val() === '2') { var re1 = /^[a-zA-Z]{5,17}$/; var re2 = /^[a-zA-Z0-9]{5,17}$/; return this.optional(element) || (re2.test(value)) || re1.test(value); } else { return true; } }, "护照格式不正确");
// 港澳通行证验证
jQuery.validator.addMethod("isHKMacao", function(value, element, type) { if ($(type).val() === '3') { var re = /^[HMhm]{1}([0-9]{10}|[0-9]{8})$/; return this.optional(element) || (re.test(value)); } else { return true; } }, "港澳通行证格式不正确");//营业执照
/^/d{15}$/
// 台湾通行证验证
jQuery.validator.addMethod("isTaiwan", function(value, element, type) { if ($(type).val() == "4") { var re1 = /^[0-9]{8}$/; var re2 = /^[0-9]{10}$/; return this.optional(element) || (re1.test(value)) || (re2.test(value)) } else { return true; } }, "台湾通行证格式不正确");
http://www.jb51.net/tools/regex.htm