JS驗證input輸入框(字母,數字,符號,中文)正則實現

 

https://www.cnblogs.com/littledonkey/p/9481782.htmlhtml

1.只能輸入英文this

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

<input type="text" onkeyup="value=value.replace(/[^\a-\z\A-\Z]/g,'')"   onkeydown="fncKeyStop(event)" onpaste="return false"   oncontextmenu="return false" />htm

3.只能輸入數字:blog

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

相關文章
相關標籤/搜索