正则表达式笔记


只能输入数字:

onkeypress='return /^\d$/.test(String.fromCharCode(event.keyCode))'
       oninput='this.value = this.value.replace(/\D+/g, "")' onpropertychange='if(!/\D+/.test(this.value)){return;};this.value=this.value.replace(/\D+/g, "")'
       onblur='this.value = this.value.replace(/\D+/g, "")'

禁止粘贴:

style="ime-mode:disabled" onpaste="return false" ondragenter="return false"

0
0

暂无评论