1、只能输入数字(小数点不能输入)
<input type="text" onkeyup="value=value.replace(/[^\d]/g,‘‘)" >
2、只能输入字母和数字(小数点不能输入)
<input onkeyup="value=value.replace(/[^\w\/]/ig,‘‘)">
3、只能输入字母和数字(小数点可以输入)
<input onkeyup="value=value.replace(/[^\w\.\/]/ig,‘‘)">
原文:https://www.cnblogs.com/wangshuaicxy/p/14356309.html