input框的输入限制

1.输入数字

<input onKeyUp="value=value.replace(/[^\d|chun]/g,'')"> 

2.只输入中文

<input type="text" onkeyup="this.value=this.value.replace(/[^\u4e00-\u9fa5]/g,'')">  

 

3.只输入英文

<input type="text" onkeyup="this.value=this.value.replace(/[^a-zA-Z]/g,'')">  

4.只输入数字,小数点也输入不了

<input onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">  

5.只能输入字母和数字

<input onkeyup="value=value.replace(/[^\w\.\/]/ig,'')">  

6.只能输入中文和字母

<input onkeyup="value=value.replace(/[\d]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))"    maxlength=10 name="Numbers"> 

posted @ 2017-08-03 15:26  。低调ヽ继续  阅读(397)  评论(0编辑  收藏  举报