[ActionScript 3.0] AS3 判断字符串是否为数字

trace(isNaN(Number("0")));//false
trace(isNaN(Number("123")));//false
trace(isNaN(Number("sw3f23")));//true
trace(isNaN(Number("swf")));//true
judgeNumber("123");//123 is number
function judgeNumber(value:String):void
{
    if(isNaN(Number(value))){
        trace(value+" is not number");
    }else{
        trace(value + " is number");
    }
}

 

------------------------------------------------------------------ Always put yourself in the other's shoes.If you feel that it hurts you,it probably hurts others,too.------------------------------------------------------------------
posted on 2015-12-29 10:43  晏过留痕  阅读(1295)  评论(0编辑  收藏  举报