1.文本框输入限制
实现限制输入大、小写英文,数字,浮点小数,日期,中文,部分英文,部分中文等众多功能。直接加入到html代码中即可使用。
小写英文:
onpaste = "return reginput(this, /^[a-z]*$/, window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^[a-z]*$/, event.datatransfer.getdata('text'))"
style="ime-mode:disabled">
大写英文:
onpaste = "return reginput(this, /^[a-z]*$/, window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^[a-z]*$/, event.datatransfer.getdata('text'))"
style="ime-mode:disabled">
任意数字:
onpaste = "return reginput(this, /^[0-9]*$/, window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^[0-9]*$/, event.datatransfer.getdata('text'))"
style="ime-mode:disabled">
限2位小数:
onpaste = "return reginput(this, /^\d*\.?\d{0,2}$/,
window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^\d*\.?\d{0,2}$/,
event.datatransfer.getdata('text'))"
style="ime-mode:disabled">
如: 123.12
日 期:
onpaste = "return reginput(this, /^\d{1,4}([-\/](\d{1,2}
([-\/](\d{1,2})?)?)?)?$/,
window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^\d{1,4}([-\/](\d{1,2}
([-\/](\d{1,2})?)?)?)?$/,
event.datatransfer.getdata('text'))"
style="ime-mode:disabled">
如: 2002-9-29
任意中文:
onpaste = "return reginput(this, /^[\u4e00-\u9fa5]*$/,
window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^[\u4e00-\u9fa5]*$/,
event.datatransfer.getdata('text'))">
部分英文:
onpaste = "return reginput(this, /^[a-e]*$/,
window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^[a-e]*$/,
event.datatransfer.getdata('text'))"
style="ime-mode:disabled">
范围: a,b,c,d,e
部分中文:
"settimeout('checkchinese(' this.value.length ',' this.uniqueid ')',
1)"
onpaste = "return reginput(this, /^[一二三四五六七八九十]*$/,
window.clipboarddata.getdata('text'))"
ondrop = "return reginput(this, /^[一二三四五六七八九十]*$/,
event.datatransfer.getdata('text'))">
范围: 一二三四五六七八九十
2.不能展开右键,不能全选,不能复制的实现
onkeypress="window.event.returnvalue=false"
onkeydown="window.event.returnvalue=false"
onkeyup="window.event.returnvalue=false"
ondragstart="window.event.returnvalue=false"
onselectstart="event.returnvalue=false">
...
3.禁止页面正文内容被选取
onselectstart ="return false" onselect="document.selection.empty()"
oncopy="document.selection.empty()" onbeforecopy="return false"onmouseup="document.selection.empty()">
4.避免别人把网页放在框架中