日期:2014-05-17  浏览次数:21158 次

怎样使文本框只能输入数字而且前面不能是0?
如果只是使文本框只能输入数字
我用onkeypress= "return   event.keyCode> =48&&event.keyCode <=57 "
但怎么防止在开头加0呢
如0025

------解决方案--------------------
onkeypress= "check() "
function check()
if mid(str,1,1)= 0 then
alert( "error! ")
exit function
end if
end function

------解决方案--------------------
if IsNumeric(request( "txt "))=True then
if left(request( "txt "),1)=0 then
Response.Write " <Script> alert( '错误:输入的数字不合法! ');history.back(-1) </script> "
Response.end
end if
else
Response.Write " <Script> alert( '错误:必须输入数字! ');history.back(-1) </script> "
Response.end
end if