//根据不同的验证内容,返回相应的正则表达式
function returnRegString(regName) { if (regName == "email") { return "^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$"; //邮箱 } else if (regName == "tel") { return "^(86)?(-)?(0[0-9]{2,3})?(-)?([0-9]{7,8})(-)?([0-9]{3,5})?$"; //电话 } else if (regName == "phone") { return "^(13[0-9]|15[0-9]|18[0-9])([0-9]{8})$"; //手机 } else if (regName == "postcode") { return "^([0-9]{6})$"; //邮编 } else if (regName == "number") { return "^(0|([1-9]+[0-9]*))(.[0-9]+)?$"; //数字 } else if (regName == "decimal") { return "^[0-9]+([.][0-9]+)?$"; //浮点 } else if (regName == "money") { return "^([0-9])$"; //货币 } else if (regName == "website") { //网址 return "(http://|https://){0,1}[w/.?&=]+"; } else if (regName == "fax") { //传真 return "^[+]{0,1}([0-9]){1,3}[ ]?([-]?(([0-9])|[ ]){1,12})+$"; } else if (regName == "int") { //整数 return "^(-){0,1}d+$"; } else if (regName == "pInt") { //正整数 return "^d+$"; } else if (regName == "nInt") { //负整数 return "^-d+$"; } else if (regName == "nandl") { //数字与字母 return "[a-zA-Z0-9]"; } else if (regName == "chinese") { //是否含有中文字符 return "[u4e00-u9fa5]"; } }