check.vs
上传用户:lwb168
上传日期:2021-10-31
资源大小:722k
文件大小:3k
源码类别:

Email服务器

开发平台:

ASP/ASPX

  1. <script language="VBScript">
  2. '** ---------------------------------------------------------------------------
  3. ' FUNCTION NAME: CheckDate
  4. ' 检查日期输入的合法性
  5. '** ---------------------------------------------------------------------------
  6. Function CheckDate(sVal)
  7. dim sYear
  8. dim sMonth
  9. dim sDay
  10. dim sMax
  11. dim sValue
  12. dim aMaxDay 
  13. sValue = SelectNum(sVal)
  14. if len(sValue) <> 8 then
  15. exit function
  16. end if
  17. aMaxDay = array(31,28,31,30,31,30,31,31,30,31,30,31)
  18. sYear = left(sValue,4)
  19. sMonth = mid(sValue,5,2)
  20. sDay = right(sValue,2)
  21. if (cInt(sMonth) > 12) or (cInt(sMonth) <= 0) then 
  22. exit function
  23. end if
  24. if sMonth = "02" then
  25. dim nCheckYear
  26. nCheckYear = cInt(sYear)
  27. if ((nCheckYear mod 4 = 0) and (nCheckYear mod 100 <> 0)) or (nCheckYear mod 400 = 0) then
  28. sMax = 29
  29. else
  30. sMax = 28
  31. end if
  32. else
  33. sMax = aMaxDay(cint(sMonth)-1)
  34. end if
  35. if (cInt(sDay) > sMax) or (CInt(sDay) <= 0 )then
  36. exit function
  37. end if
  38. CheckDate = sYear & "-" & sMonth & "-" & sDay
  39. End Function
  40. Sub IntNum_onBlur(iNum)
  41.     Dim id 
  42.     Dim tVal,v1,v2
  43.     Set id = window.document.all(iNum)
  44.     If trim(id.value) <> "" Then
  45.        tVal = trim(id.value)
  46.        if IsIntNum(tVal) = "" then                  '调用检查函数
  47.    id.value = ""
  48.    MsgBox( "必须为整数。请重新输入!")
  49.    id.focus
  50.    Exit Sub
  51. End if
  52.      End If
  53.      Set id = nothing
  54. End Sub
  55. Sub Num_onBlur(iNum)
  56.     Dim id 
  57.     Dim tVal,v1,v2
  58.     Set id = window.document.all(iNum)
  59.     If trim(id.value) <> "" Then
  60.        tVal = trim(id.value)
  61.        if IsNum(tVal) = "" then                     '调用检查函数
  62.   id.value = ""
  63.   MsgBox( "有无效字符。请重新输入")
  64.   id.focus
  65.   Exit Sub
  66.        End if
  67.     End If
  68.     Set id = nothing
  69. End Sub
  70. '** ---------------------------------------------------------------------------
  71. ' 功能:判断输入的字符串是否是数字和小数点
  72. '** ---------------------------------------------------------------------------
  73. Function IsNum(sVal)
  74.        Dim i,j
  75.        j=1
  76.        dim sResult
  77.        sResult = true
  78.        for i = 1 to len(sVal)                        '逐个字符比较检查
  79.    if ((asc(mid(sVal,i,1))) < 48) or ((asc(mid(sVal,i,1))) > 58) then
  80.       if ((asc(mid(sVal,i,1))) <> 46) then   '判断是否为小数点
  81.  exit function
  82.               else
  83.                  if j>1 then                         '判断是否含有一个以上的小数点
  84.                     exit function
  85.                  else
  86.                     j=j+1
  87.                  end if   
  88.        end if
  89.     end if
  90. next
  91.      IsNum = sResult
  92. End Function
  93. '** ---------------------------------------------------------------------------
  94. ' 功能:判断输入的字符串是否是数字
  95. '** ---------------------------------------------------------------------------
  96. Function IsIntNum(sVal)
  97. dim i
  98. dim sResult
  99. sResult = true
  100. for i = 1 to len(sVal)                       '逐个字符比较检查
  101.     if ((asc(mid(sVal,i,1))) < 48) or ((asc(mid(sVal,i,1))) > 58) then
  102. exit function
  103.     end if
  104. next
  105. IsIntNum = sResult
  106. End Function
  107. </Script>