好像isNan只能判断头一个字符

解决方案 »

  1.   

    if(!isNaN(str))
    alert("是数字");-----------------------
    if (/^\d+$/.test(str))
      alert("是数字");
      

  2.   

    function isnumber(phone) {
    var endvalue,allowstrlist;
    endvalue=true;

    allowstrlist="1234567890,.";
    for (i=0;i<phone.length;i++) {
    if (allowstrlist.indexOf(phone.substr(i,1))==-1) {
    endvalue=false;
    break;
    }
    }
    return(endvalue);
    }
      

  3.   

    //str="asdfasdf";
    str="12.23"
    if (/^\-?\d+\.?\d*$/.test(str))
      alert("是数字");