减小字体 增大字体
] 源码如下----------------------------------------------------------<style>body,td,div,a,input,xmp{font:menu}</style><script>function tofloat(f,dec){ if(dec<0) return "Error:dec<0!"; result=parseInt(f)+(dec==0?"":"."); f-=parseInt(f); if(f==0) for(i=0;i<dec;i++) result+='0'; else { for(i=0;i<dec;i++) f*=10; result+=parseInt(Math.round(f)); } return result;}window.status=tofloat(11.20000000000000000001,5);</script>检查一段字符串是否全由数字组成,如果是,返回true 如果否,返回false<xmp><script>function checkNum(str){return str.match(/\D/)==null}alert(checkNum("1232142141"))alert(checkNum("123214214a1"))</script></xmp><xmp><script language=javascript><!--function StrCh(str){ var s; for (i = 0; i < str.length; i++){ s = str.charCodeAt(i); if (!((s>=48) && (s<= 57))) return false; } return true;}if(StrCh("124182787"))alert("true");if(!StrCh("28980OOP"))alert("false");// --></script></xmp>
[提示:你可先按照下面代码提示修改 上面部分代码,再按运行,此处看到的演示不完全正确]