function testCheck(str){
if(!str.match(/^\d+$/))
           alert(非法);
}

解决方案 »

  1.   

    to mingxuan3000(铭轩) :不是吧  不是分 string number boolean object .... 很多吗?to hanpoyangtitan(韩波洋)谢谢你提供一个正则表达式 但是....  要是有小数点呢? 小数点 可不在 \d里哦....
      

  2.   

    if(!str.match(/^([1-9]\d*|0)(\.\d+)?$/))
      

  3.   

    恩 谢谢 hbhbhbhbhb1021(天外水火(我要多努力))   你的 正则表达式 写的不错但是 我的关键问题是 为什么  typeof 不起作用  我传入的str 即使是  Integer.pasInt(value)  它检测出 还是 string  我迷茫了....
      

  4.   

    function testCheck(str){
    try{
      str=parseFloat(str);
    }
    catch(e)
    {
      alert(e);
    }
    if(typeof(str)=="string")
               alert("string");
    }
      

  5.   

    to:hanpoyangtitan(韩波洋)  能说几句话吗?不懂你什么意思.....
      

  6.   

    <td><input type=text name="num" size="25"><%=value%></td>
    到了客户端的时候
    <td><input type=text name="num" size="25">12.3</td>
    不管你在服务器端是什么数据类型
    到了客户端都是一个样子了
    都是string 你可以用正则表达式 来判断了
      

  7.   

    typeOf()一般用来判断“undefined”的
    js中因为交互过程中数据用流传输的,所以解析到页面都是字符串的
    数据类型校验用正则才好~~~