日期:2014-05-17 浏览次数:20696 次
<script>
function test(){
var nums=[123.1234, 12.1234, 1.1234, 1234, 123, 12, 1, 0, .1, 0.2, 0.12, 0.123, 1.1, 1.12, 1.123, 10.1, 10.12, 10.123, 345.1, 345.12, 345.123];
var reg=/^\d*(\.\d{0,2})?$/;
var len=nums.length;
for(var i=0;i<len;i++){
document.writeln("current.num="+nums[i]+", bool="+reg.test(nums[i])+"<br>");
}
}
test();
</script>