如果允许用户名是"0~9" "a~z" "A~Z" 和下划线"_",vbScript代码怎写?

ljty 2001-10-30 04:46:45
如果允许用户名是"0~9" "a~z" "A~Z" 和下划线"_",
vbScript代码怎写?
...全文
2083 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go_Rush 2001-10-31
  • 打赏
  • 举报
回复
给你一最短的:

dim userid,objRegExp
userid="Go_Rush" 'userid=request.form("userid")
Set objRegExp=new RegExp
objRegExp.IgnoreCase =true
objRegExp.Global=True

'改变{1,}中的值还可以限制用户名的长度,如:{3,8}是限制最短3个字符,最长8个字符, 下例是最短一个字符,最长任意多个字符
objRegExp.Pattern="^[A-Za-z0-9_]{1,}$"

if not objRegExp.Test(userid) then response.write "请输入正确的用户名"
set objregexp=nothing
kjn 2001-10-31
  • 打赏
  • 举报
回复
关注
tonnycncn 2001-10-30
  • 打赏
  • 举报
回复
不如用javascript!
<script language="javascript">
function IsDigit(cCheck)
{
return (('0'<=cCheck) && (cCheck<='9'));
}

function IsAlpha(cCheck)
{
return ((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
}

function IsaNull(cCheck)
{
return(cCheck != " ")
}

function checkform()
{
strUserID = document.sform1.username.value;
if (strUserID == "")
{
alert("请输入注册名");
document.sform1.username.focus();
return false;
}

for (nIndex=0; nIndex<strUserID.length; nIndex++)
{
cCheck = strUserID.charAt(nIndex);
if (!(IsDigit(cCheck) || IsAlpha(cCheck) || cCheck=='-' || cCheck=='_' || cCheck=='.'))
{
alert("用户名只能使用字母、数字以及-、_和.,并且不能使用中文");
document.sform1.username.focus();
return false;
}
}
}
hmbory 2001-10-30
  • 打赏
  • 举报
回复
name1=lcase(name)
for aa=1 to len(name1)
dd=mid(name1,aa,1)
if dd>="!"and dd<"A" or dd>="["and dd<="`" or dd>="{"and dd<="~"or dd=" " then
Response.Redirect ("sorry.asp?id=请输好!")
end if
next
hongfan 2001-10-30
  • 打赏
  • 举报
回复
name_unit=mid(username,1,1)
if not (((asc(name_unit)>64 and asc(name_unit)<91)) or ((asc(name_unit)>96 and asc(name_unit)<123))) then
displayInfo("请正确输入用户名")
response.End
end if
for i=1 to name_length
name_unit=mid(username,i,1)
if asc(name_unit)<48 then
displayInfo("请正确输入用户名")
response.End
end if
if asc(name_unit)>57 and asc(name_unit)<65 then
displayInfo("请正确输入用户名")
response.End
end if
if asc(name_unit)>90 and asc(name_unit)<97 and asc(name_unit)<>95 then
displayInfo("请正确输入用户名")
response.End
end if
if asc(name_unit)>122 then
displayInfo("请正确输入用户名")
response.End
end if
next

28,390

社区成员

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

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