公用js方法

戏子无情 提交于 2020-02-22 12:20:06

1.js全局替换空格,制表符,换行符  oninput = "value=value.replace(/\s+/g,'')"

<input type="text" id="productTransactionCode" value="" oninput = "value=value.replace(/\s+/g,'')"
      placeholder="若此项不填,无法关联主站出单" οnblur="checkExistence('code关联重复')"/>

2.控制input框只让输入数字 oninput = "value=value.replace(/[^\d]/g,'')"

<input type="text" id="payment" oninput = "value=value.replace(/[^\d]/g,'')" value="" placeholder="缴费年期必须是数字"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!