使input框只能输入数字—简单方法

在Input框加上  onkeyup="value=value.replace(/[^\d]/g,'')"   就可以

<input type="text" id="class_rate_percent" class="wsinput" value="" onkeyup="value=value.replace(/[^\d]/g,'')"/>

 要数字带小数点的,代码上多加个点

<input type="text" id="class_rate_percent" class="wsinput" value="" onkeyup="value=value.replace(/[^\d.]/g,'')"/>

 

posted on 2018-08-14 10:59  super_bobo  阅读(2949)  评论(0编辑  收藏  举报