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

时间:2022-04-15 02:26:39
  1. <%  
  2. '******************************  
  3. '函数:IsValidUserName(byVal UserName)  
  4. '参数:UserName,用户名称  
  5. '作者:阿里西西  
  6. '日期:2007/7/15  
  7. '描述:验证用户名是否包含有非法字符,不含非法字符返回:true  
  8. '示例:IsValidUserName(byVal UserName)  
  9. '******************************  
  10. Function IsValidUserName(byVal UserName)  
  11.  Dim i,c  
  12.  IsValidUserName = True  
  13.  For i = 1 To Len(UserName)  
  14.   c = Lcase(Mid(UserName, i, 1))  
  15.   If InStr("$!<>?#^%@~`&*();:+='""   ", c) > 0 Then  
  16.     IsValidUserName = False  
  17.     Exit Function  
  18.   End IF  
  19.  Next  
  20. End Function  
  21. %>