check.vs
资源名称:imail.rar [点击查看]
上传用户:lwb168
上传日期:2021-10-31
资源大小:722k
文件大小:3k
源码类别:
Email服务器
开发平台:
ASP/ASPX
- <script language="VBScript">
- '** ---------------------------------------------------------------------------
- ' FUNCTION NAME: CheckDate
- ' 检查日期输入的合法性
- '** ---------------------------------------------------------------------------
- Function CheckDate(sVal)
- dim sYear
- dim sMonth
- dim sDay
- dim sMax
- dim sValue
- dim aMaxDay
- sValue = SelectNum(sVal)
- if len(sValue) <> 8 then
- exit function
- end if
- aMaxDay = array(31,28,31,30,31,30,31,31,30,31,30,31)
- sYear = left(sValue,4)
- sMonth = mid(sValue,5,2)
- sDay = right(sValue,2)
- if (cInt(sMonth) > 12) or (cInt(sMonth) <= 0) then
- exit function
- end if
- if sMonth = "02" then
- dim nCheckYear
- nCheckYear = cInt(sYear)
- if ((nCheckYear mod 4 = 0) and (nCheckYear mod 100 <> 0)) or (nCheckYear mod 400 = 0) then
- sMax = 29
- else
- sMax = 28
- end if
- else
- sMax = aMaxDay(cint(sMonth)-1)
- end if
- if (cInt(sDay) > sMax) or (CInt(sDay) <= 0 )then
- exit function
- end if
- CheckDate = sYear & "-" & sMonth & "-" & sDay
- End Function
- Sub IntNum_onBlur(iNum)
- Dim id
- Dim tVal,v1,v2
- Set id = window.document.all(iNum)
- If trim(id.value) <> "" Then
- tVal = trim(id.value)
- if IsIntNum(tVal) = "" then '调用检查函数
- id.value = ""
- MsgBox( "必须为整数。请重新输入!")
- id.focus
- Exit Sub
- End if
- End If
- Set id = nothing
- End Sub
- Sub Num_onBlur(iNum)
- Dim id
- Dim tVal,v1,v2
- Set id = window.document.all(iNum)
- If trim(id.value) <> "" Then
- tVal = trim(id.value)
- if IsNum(tVal) = "" then '调用检查函数
- id.value = ""
- MsgBox( "有无效字符。请重新输入")
- id.focus
- Exit Sub
- End if
- End If
- Set id = nothing
- End Sub
- '** ---------------------------------------------------------------------------
- ' 功能:判断输入的字符串是否是数字和小数点
- '** ---------------------------------------------------------------------------
- Function IsNum(sVal)
- Dim i,j
- j=1
- dim sResult
- sResult = true
- for i = 1 to len(sVal) '逐个字符比较检查
- if ((asc(mid(sVal,i,1))) < 48) or ((asc(mid(sVal,i,1))) > 58) then
- if ((asc(mid(sVal,i,1))) <> 46) then '判断是否为小数点
- exit function
- else
- if j>1 then '判断是否含有一个以上的小数点
- exit function
- else
- j=j+1
- end if
- end if
- end if
- next
- IsNum = sResult
- End Function
- '** ---------------------------------------------------------------------------
- ' 功能:判断输入的字符串是否是数字
- '** ---------------------------------------------------------------------------
- Function IsIntNum(sVal)
- dim i
- dim sResult
- sResult = true
- for i = 1 to len(sVal) '逐个字符比较检查
- if ((asc(mid(sVal,i,1))) < 48) or ((asc(mid(sVal,i,1))) > 58) then
- exit function
- end if
- next
- IsIntNum = sResult
- End Function
- </Script>