1.input里面可以带小数点
onkeyup= "if(!/^\d{0,30}$/.test(this.value)){this.value=this.value.replace(/[^\d.]/g, '');}"
<input type="text" name="number" onkeyup= "if(!/^\d{0,30}$/.test(this.value)){this.value=this.value.replace(/[^\d.]/g, '');}">
2.input 里面不可以带小数点
onkeyup= "if(!/^\d{0,30}$/.test(this.value)){this.value=this.value.replace(/[^0-9]/g, '');}"
<input type="text" name="number" onkeyup= "if(!/^\d{0,30}$/.test(this.value)){this.value=this.value.replace(/[^0-9]/g, '');}">
网友评论