求手机号码正则表达式

高分请教一下,求手机号码正则表达式
最新回答
醉酒吟春秋

2024-04-11 00:47:38

完整版:#####函数代码######## 假设为myfunc.asp<%'正则表表达式验证函数 patrn-正则表达式 strng-需要验证的字符串 Function RegExpTest(patrn, strng) Dim regEx, retVal ' 建立变量。 Set regEx = New RegExp ' 建立正则表达式。 regEx.Pattern = patrn ' 设置模式。 regEx.IgnoreCase = False ' 设置是否区分大小写。 retVal = regEx.Test(strng) ' 执行搜索测试。 RegExpTest = retVal '返回不尔值,不符合就返回false,符合为true End Function%#####提交页面代码###### 假设为mypage.asp <form method="post" action="check.asp" 请输入E-mail地址:<input type=text name=email 请输入电话号码:<input type=text name=tel <input type=submit value="确定"</form#####验证页面######## 假设为check.asp <!--#include file="myfunc.asp"--<%tel=request.form("tel") email=request.form("email") dim founderr : founderr=false '建立变量,正确或者失败标记 '大家注意哦,顺便我在这里贡献一个正则表达式,同时验证电话号码和手机号码的! if RegExpTest("(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)", tel)=false then founderr=true regshow=regshow&"<li您输入的电话号码格式不正确"end ifif RegExpTest("^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$", email)=false then founderr=true