當柳上原的風吹向天際的時候...

          真正的快樂來源于創造

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            368 Posts :: 1 Stories :: 201 Comments :: 0 Trackbacks
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
          <html>
           <head>
            <title> New Document </title>
            <meta name="Generator" content="EditPlus">
            <meta name="Author" content="">
            <meta name="Keywords" content="">
            <meta name="Description" content="">
           </head>

           <body>
          <input id="decimalTxt" />&nbsp;
          <button id="showBtn" >Click</button>
           </body>
          </html>
          <script type="text/javascript">
          <!--
          window.onload=function(){
              document.getElementById("showBtn" ).onclick=function(){
                  var value=document.getElementById("decimalTxt" ).value;
                  alert(toCurrency(value));
              };
          };

          function toCurrency(money) {  
             if (/[^0-9\.]/.test(money)){
                  return '0.00';
              }

              money = money.replace(/^(\d*)$/, "$1.");
              money = (money + "00").replace(/(\d*\.\d\d)\d*/, "$1");
              money = money.replace(".", ",");
              var re = /(\d)(\d{3},)/;
              while (re.test(money)) {
                  money = money.replace(re, "$1,$2");
              }
              money = money.replace(/,(\d\d)$/, ".$1");

              return '' + money.replace(/^\./, "0.");
          }  
          //-->
          </script>
          posted on 2013-02-18 16:30 何楊 閱讀(1193) 評論(0)  編輯  收藏 所屬分類: JavaScript
          主站蜘蛛池模板: 达州市| 吉木萨尔县| 乐山市| 同德县| 伊通| 水城县| 顺昌县| 江山市| 兴城市| 绥滨县| 五大连池市| 墨竹工卡县| 洪洞县| 西充县| 临潭县| 吉林省| 长治县| 米易县| 屏边| 淮南市| 中方县| 敦煌市| 平乡县| 克东县| 嘉善县| 长垣县| 龙口市| 古田县| 信丰县| 克东县| 合水县| 三门县| 清河县| 信宜市| 兴山县| 仪征市| 墨玉县| 瓮安县| 临海市| 泸州市| 曲麻莱县|