利用正則表達式(只錄入中文,數(shù)字,英文)
更新時間:2009年08月24日 02:15:29 作者:
利用正則表達式(只錄入中文,數(shù)字,英文)限制的代碼,好多情況下都需要。
只能輸入中文:<input id="input1" type="text" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')">
只能輸入全角字符:<input id="input2" type="text" onkeyup="value=value.replac(/[^\u4E00-\u9FA5]/g,'')">
只能輸入數(shù)字:<input id="input3" type="text" onkeyup="value=value.replace(/[^\d]/g,'') ">
只能輸入數(shù)字和英文:<input id="input4" type="text" onkeyup="value=value.replace(/[\W]/g,'')">
只能輸入全角字符:<input id="input2" type="text" onkeyup="value=value.replac(/[^\u4E00-\u9FA5]/g,'')">
只能輸入數(shù)字:<input id="input3" type="text" onkeyup="value=value.replace(/[^\d]/g,'') ">
只能輸入數(shù)字和英文:<input id="input4" type="text" onkeyup="value=value.replace(/[\W]/g,'')">
相關文章
Java用正則對字符串進行處理并判斷是否能轉為數(shù)字
這篇文章主要介紹了Java用正則對字符串進行處理并判斷是否能轉為數(shù)字的實例代碼,代碼很簡單,需要的朋友可以參考下2018-06-06

