又一个判断email合法性的函数

没用到正则,看起来这个函数的准确度还是比较高的。
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
  1. <
  2. Function IsValidEmail(email) 
  3. Dim names, Name, i, c 
  4. IsValidEmail = True 
  5. names = Split(email, "@") 
  6. If UBound(names) <> 1 Then 
  7. IsValidEmail = False 
  8. Exit Function 
  9. End If 
  10. For Each Name In names 
  11. If Len(Name) <= 0 Then 
  12. IsValidEmail = False 
  13. Exit Function 
  14. End If 
  15. For i = 1 To Len(Name) 
  16. c = LCase(Mid(Name, i, 1)) 
  17. If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then 
  18. IsValidEmail = False 
  19. Exit Function 
  20. End If 
  21. Next 
  22. If Left(Name, 1) = "." Or Right(Name, 1) = "." Then 
  23. IsValidEmail = False 
  24. Exit Function 
  25. End If 
  26. Next 
  27. If InStr(names(1), ".") <= 0 Then 
  28. IsValidEmail = False 
  29. Exit Function 
  30. End If 
  31. i = Len(names(1)) - InStrRev(names(1), ".") 
  32. If i <> 2 And i <> 3 Then 
  33. IsValidEmail = False 
  34. Exit Function 
  35. End If 
  36. If InStr(email, "..") > 0 Then 
  37. IsValidEmail = False 
  38. End If 
  39. End Function 
  40. %> 
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值