java中如何校验输入的数据是否为数字呢??

2024-11-18 13:53:08
推荐回答(1个)
回答(1):

//数字判断1
function IsNumeric(s)
{
for (var i=0; ivar c = s.charAt(i);
if (c<'0' || '9'return false;
}
}
return true
}

//数字判断2
function IsNumeric2(s)
{
for (var i=0; ivar c = s.charAt(i);
if (c!=' ') {
if (c<'0' || '9'return false
}
}
}
return true;
}

//数字判断3
function IsAlphaNumeric(s)
{
for (var i=0; ivar c = s.charCodeAt(i);
if (!(0x0020<=c && c<=0x007e)) return false;
}
return true;
}