- html代码:
<input class="form-control type="text" placeholder="0" onkeyup="onlyNum(this)" />
- js代码
//判断只能输入数字,非数字替换为kon
obj.value = obj.value.replace(/\D/g,"");
}
转载至:https://blog.csdn.net/mathilda001/article/details/76031917