if (parseFloat(num)!=num){
alert("no");
}

解决方案 »

  1.   

    楼主写一个函数就好public boolean isNumber(String s){
      try{
         Integer.parseInt(s);
         return true;
      }catch(Exception e){
         return false;
      }
    }如果需要判断这个String是否double, 只要把上面的Integer改成Double就可以。然后在楼主代码??的地方用 isNumber(syear)  代替就可以
      

  2.   

    别忘了用try {
    catch (NumberFormatException)
      

  3.   

    isNaN(double v) 
         Returns true if the specified number is the special Not-a-Number (NaN) value.
    布尔类型的,你可以查看JDK帮助文档