asp 验证用户名是否包含有非常字符的函数

  <%

  '******************************

  '函数:IsValidUserName(byVal UserName)

  '参数:UserName,用户名称

  '作者:阿里西西

  '日期:2007/7/15

  '描述:验证用户名是否包含有非法字符,不含非法字符返回:true

  '示例:IsValidUserName(byVal UserName)

  '******************************

  Function IsValidUserName(byVal UserName)

  Dim i,c

  IsValidUserName = True

  For i = 1 To Len(UserName)

  c = Lcase(Mid(UserName, i, 1))

  If InStr("$!<>?#^%@~`&*();:+='""   ", c) > 0 Then

  IsValidUserName = False

  Exit Function

  End IF

  Next

  End Function

  %>