2014-12-03 60 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