asp数字验证

来源:百度知道 编辑:UC知道 时间:2024/05/31 12:51:38
isNum=/^[0-9]$/
上面的数只是表示数据0-9的范围,如果要表示只要是数字就行的范围,应怎样写??

举个例子你就懂了:
Dim haha1,haha2
haha1=128
haha2="Not a Number"
if IsNumeric(haha1) then
response.write "haha1这个变量是数字"
else
response.write "haha1这个变量不是数字"
end if

if IsNumeric(haha2) then
response.write "haha2这个变量是数字"
else
response.write "haha2这个变量不是数字"
end if

if IsNumeric(haha1) then这句还可以这么写:
if IsNumeric(haha1)=true then

IsNumeric IsNumeric函数确定变量是否具有数值子类或表达式是否能赋成数值。
用法为:bool = IsNumeric(expr)
当expr能赋成数时bool为True。