2014-12-03 59 views
0

如何申請使用我的代碼Ctrl+A全選?如何申請使用我的代碼Ctrl + A選擇全部?

http://jsfiddle.net/Fp4sJ/806/

首先,填充數EG: 333.44到輸入,然後按鍵Ctrl + A鍵。

爲什麼不選擇輸入中的所有數據,我該如何申請?

<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script> 

<script type="text/javascript"> 
$(window).load(function(){ 
$(".allownumericwithdecimal").on("keypress keyup blur",function (event) { 
      //this.value = this.value.replace(/[^0-9\.]/g,''); 
    $(this).val($(this).val().replace(/[^0-9\.]/g,'')); 
      if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) { 
       event.preventDefault(); 
      } 
     }); 

}); 
</script> 

<input type="text" name="numeric" class='allownumericwithdecimal'> 
+0

它的作品,如果你拿出那個JavaScript,或只是使用按鍵。使用一個輸入類型=數字,而不是離邊JS。 – dandavis 2014-12-03 05:43:25

回答

1

從這裏事件刪除 「KEYUP」 觸發:

$(".allownumericwithdecimal").on("keypress keyup blur",function (event) { 

給它這樣的

$(".allownumericwithdecimal").on("keypress blur",function (event) { 
0

刪除此行

event.preventDefault();

+0

它的工作,但不保存功能浮點輸入。 – 2014-12-03 06:03:46