chkinput.asp
上传用户:comthink
上传日期:2021-05-06
资源大小:1280k
文件大小:2k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. <%
  2. Rem ==========同学录通用函数=========
  3. '邮件有效检查
  4. function IsValidEmail(email)
  5. dim names, name, i, c
  6. IsValidEmail = true
  7. names = Split(email, "@")
  8. if UBound(names) <> 1 then
  9.    IsValidEmail = false
  10.    exit function
  11. end if
  12. for each name in names
  13.    if Len(name) <= 0 then
  14.      IsValidEmail = false
  15.      exit function
  16.    end if
  17.    for i = 1 to Len(name)
  18.      c = Lcase(Mid(name, i, 1))
  19.      if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
  20.        IsValidEmail = false
  21.        exit function
  22.      end if
  23.    next
  24.    if Left(name, 1) = "." or Right(name, 1) = "." then
  25.       IsValidEmail = false
  26.       exit function
  27.    end if
  28. next
  29. if InStr(names(1), ".") <= 0 then
  30.    IsValidEmail = false
  31.    exit function
  32. end if
  33. i = Len(names(1)) - InStrRev(names(1), ".")
  34. if i <> 2 and i <> 3 then
  35.    IsValidEmail = false
  36.    exit function
  37. end if
  38. if InStr(email, "..") > 0 then
  39.    IsValidEmail = false
  40. end if
  41. end function
  42. '判断汉字长度
  43. function strLength(str)
  44.        ON ERROR RESUME NEXT
  45.        dim WINNT_CHINESE
  46.        WINNT_CHINESE    = (len("同学录")=3)
  47.        if WINNT_CHINESE then
  48.           dim l,t,c
  49.           dim i
  50.           l=len(str)
  51.           t=l
  52.           for i=1 to l
  53.              c=asc(mid(str,i,1))
  54.              if c<0 then c=c+65536
  55.              if c>255 then
  56.                 t=t+1
  57.              end if
  58.           next
  59.           strLength=t
  60.        else 
  61.           strLength=len(str)
  62.        end if
  63.        if err.number<>0 then err.clear
  64. end function
  65. '标题缩短函数
  66. function cutStr(str,strlen)
  67. dim l,t,c
  68. l=len(str)
  69. t=0
  70. for i=1 to l
  71. c=Abs(Asc(Mid(str,i,1)))
  72. if c>255 then
  73. t=t+2
  74. else
  75. t=t+1
  76. end if
  77. if t>=strlen then
  78. cutStr=left(str,i)&"..."
  79. exit for
  80. else
  81. cutStr=str
  82. end if
  83. next
  84. cutStr=replace(cutStr,chr(10),"")
  85. end function
  86. %>