这一正则表达式判断错在哪里??? 请求帮助!在线等-----

ghost_zhihan 2005-06-09 03:30:48
怎么才能验证输入的字符只能是英文字符,数字和下划线

我在后台是这么验证的,不能通过。请求大们的帮助~!

if checkexp("^\\w+$",request.Form("textfield20"))=false then
Response.write "<script language='JavaScript'>alert('用户名只能是英文字符,数字和下划线。');window.history.go(-1)</script>"
response.end
end if

' 正则表达式检查数据。
public function checkexp(patrn,strng) 'partrn为正则表达式;strng为提交的数据
dim regex,match
set regex=new regexp
regex.pattern=patrn
regex.Ignorecase=false
regex.global=true
matches=regex.test(strng)
checkexp=matches
end function
...全文
85 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
netWild 2005-06-09
  • 打赏
  • 举报
回复
function findBadChar(stra)
dim str
str = stra
set RegEx = new RegExp
RegEx.Pattern="[^A-Za-z0-9_]"
RegEx.IgnoreCase = true
RegEx.Global = True
findBadChar = RegEx.test(str)
end function

if findBadChar(request.Form("textfield20"))=true then
Response.write "<script language='JavaScript'>alert('用户名只能是英文字符,数字和下划线。');window.history.go(-1)</script>"
response.end
end if

ghost_zhihan 2005-06-09
  • 打赏
  • 举报
回复
大大们,来看看啊~~~

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧