input的onchange事件 及只能输入数字实现
2017-09-06 00:00
513 查看
摘要: input内容发生变化时 需要出发一些动作
input输入框只能输入数字:
输入整数或者小数:
控制输入金额:
<input type="text" class="currentPage"> <script> // method1 $(".currentPage").on('input',function(e){ alert("TextChanged!") ; }); //method2 $(".currentPage").bind("propertychange input",function(){ alert("TextChanged!") ; }) </script>
input输入框只能输入数字:
<input id="xxx" type="number" onKeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))"/>
输入整数或者小数:
<input id="xxx" type="number" onKeypress="return (/[\d+([.]\d)]/.test(String.fromCharCode(event.keyCode)))"/>
控制输入金额:
$("#withdrawAmount").change(function(){ if (utils.isEmpty(this.value)){ this.value = 0; } else if (this.value > can_out_amount){ var s_amount = can_out_amount.toString(); this.value = s_amount; if (s_amount.indexOf('.') > 0) { this.value = s_amount.substring(0, s_amount.indexOf('.')); } } });
相关文章推荐
- js实现input输入框只能输入数字的功能(完美测试通过)
- js实现input输入框只能输入数字的功能
- 实现只能输入数字的input不用replace方法
- 不用replace方法,实现 - 只能输入数字的input
- js实现input输入框只能输入数字的功能(完美测试通过)
- 不用replace方法,实现 - 只能输入数字的input
- 『JavaScript』限制Input只能输入数字实现思路及代码
- js实现input输入框只能输入数字的功能
- input框设置onKeypress事件只能输入数字(兼容火狐和IE9)
- js实现input输入框只能输入数字的功能(完美测试通过)
- 『JavaScript』限制Input只能输入数字实现思路及代码
- C#--关于事件的定义及注册,如何实现在一个文本框中只输入数字或者只能输入0至9十种数字、a至z或A至Z五十二种字符。
- input框设置onInput事件只能输入数字,能兼容火狐IE9
- 实现只能输入数字的input不用replace方法
- js实现input输入框只能输入数字的功能(完美测试通过)
- input标签只能输入数字js实现(且不能输入e或者其他各种符号)
- HTML中input只能输入数字(键盘抬起和粘贴事件)
- js、正则限制input输入框只能输入数字或者小数
- js实现限制输入框只能输入数字
- input为number的时候设置只能输入数字的正则