只能输入汉字(有闪动):
- onkeyup="this.value=this.value.replace(/[^\\u4E00-\\u9FA5]/g,'')" />
只能输入数字(有闪动):
- onkeyup="this.value=this.value.replace(/[^\d]/g,'')" />
只能输入汉字、字母和数字(无闪动):
- onkeypress="return /[\w\\u4e00-\\u9fa5]/.test(String.fromCharCode(window.event.keyCode))"
- onpaste="return !/[^\w\\u4e00-\\u9fa5]/g.test(window.clipboardData.getData('Text'))"
- ondragenter="return false"/>
閱讀更多 JAVA技術開發 的文章