前端校验只能输入数字

前端校验只能输入数字

<input name="elementLength" maxlength="8"
 onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v(); type="text" class="required"/>

原文地址:https://www.cnblogs.com/pai-da-xing/p/8065949.html