asp网页中怎样用脚本代码判断表单文本框中输入的是否是数字和整数??

如题所述

第1个回答  2011-10-11
'函数名:isInteger
'作 用:整数检验
'参 数:tstr ----字符
'返回值:true是整数,false不是整数
'
Public function isInteger(para)
on error resume Next
Dim str
Dim l,i
If isNUll(para) then
isInteger=false
exit function
End if
str=cstr(para)
If trim(str)= then
isInteger=false
exit function
End if
l=len(str)
For i=1 to l
If mid(str,i,1)9 or mid(str,i,1)0 then
isInteger=false
exit function
End if
Next
isInteger=true
If err.number0 then err.clear
End Function

//''''''''''''''''''''''''''''''''''''''
//isnuberic检测是否为数字

if not isnumberic(CheckString) then
TxtCheck=ErrorRoot&"不是数字"
exit function
else
if CheckLength <> "" then
TxtCheck=Left(CheckString,CheckLength)
else
TxtCheck=CheckString
End if
end if