<div class="codetitle"> <span><a style="CURSOR: pointer" data="17460" class="copybut" id="copybut17460" onclick="doCopy('code17460')"><u>複製程式碼</u></a></span> 代碼如下:</div> <div class="codebody" id="code17460"> <br><br><br><br><br><br><br><br><br> <meta charset="UTF-8"> <br> <title>Test</title> <br> <title>Test</title> <br> "><br> <br> <script type="text/javascript"><BR> $(document).ready(f <BR> $("#Score").bind("keypress", function(event) {<BR> //控制第一個不能輸入小數點" ."<BR> if (getValue.length == 0 && event.which == 46) {<BR> event.preventDefault();<BR> return;<BR> }<BR> //控制只能輸入一個小數點"."<BR> .preventDefault();<BR> return;<BR> > //控制只能輸入的值<BR> .which != 46) {<BR> event.preventDefault();<BR> return;<BR> }<BR> })<BR> //失去焦點是觸發<BR> $("#Score").bind("blur", function(event ) {<BR> var value = $(this).val(), reg = /.$/;<BR> value = value.replace(reg, "" );<BR> $(this).val(value);<BR> })<BR> });<BR> </script><br> <br> <input type="text" id="Score"><br> <br> </div>