正則匹配中文字符,使用unicode編碼:
匹配中文字符的正則表達(dá)式: [\u4e00-\u9fa5]
用正則表達(dá)式限制只能輸入中文:onkeyup="value=value.replace(/[^u4E00-u9FA5]/g,') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^u4E00-u9FA5]/g,'))"
用正則表達(dá)式限制只能輸入全角字符: onkeyup="value=value.replace(/[^uFF00-uFFFF]/g,') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^uFF00-uFFFF]/g,'))"
用正則表達(dá)式限制只能輸入數(shù)字:onkeyup="value=value.replace(/[^d]/g,') "onbeforepaste= "clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,'))"
用正則表達(dá)式限制只能輸入數(shù)字和英文:onkeyup="value=value.replace(/[W]/g,') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,'