This Domain(Admin5.com) is for Sale:

互联网页面浏览限制实现总结

时间:2007-12-27  来源:不详  作者:林子

1.文本框输入限制

  实现限制输入大、小写英文,数字,浮点小数,日期,中文,部分英文,部分中文等众多功能。直接加入到html代码中即可使用。

copyright dedecms

dedecms.com

<script> 本文来自织梦

function regInput(obj, reg, inputStr) 织梦好,好织梦

{ 本文来自织梦

var docSel = document.selection.createRange() copyright dedecms

if (docSel.parentElement().tagName != "INPUT") return false copyright dedecms

oSel = docSel.duplicate()

本文来自织梦

oSel.text = ""

织梦内容管理系统

var srcRange = obj.createTextRange() dedecms.com

oSel.setEndPoint("StartToStart", srcRange) 本文来自织梦

var str = oSel.text inputStr srcRange.text.substr(oSel.text.length)

本文来自织梦

return reg.test(str)

织梦好,好织梦

} 织梦好,好织梦

</script>
小写英文:<xmp style= "display:inline"> </xmp> copyright dedecms

<input onkeypress = "return regInput(this, /^[a-z]*$/, String.fromCharCode(event.keyCode))"

dedecms.com

onpaste = "return regInput(this, /^[a-z]*$/, window.clipboardData.getData('Text'))" 本文来自织梦

ondrop = "return regInput(this, /^[a-z]*$/, event.dataTransfer.getData('Text'))" dedecms.com

style="ime-mode:Disabled"

内容来自dedecms

><br>
大写英文:<xmp style= "display:inline"> </xmp> 织梦好,好织梦

<input onkeypress = "return regInput(this, /^[A-Z]*$/, String.fromCharCode(event.keyCode))" 织梦内容管理系统

onpaste = "return regInput(this, /^[A-Z]*$/, window.clipboardData.getData('Text'))"

dedecms.com

ondrop = "return regInput(this, /^[A-Z]*$/, event.dataTransfer.getData('Text'))" copyright dedecms

style="ime-mode:Disabled"> 织梦内容管理系统

<br>
任意数字:<xmp style="display:inline"> </xmp> 本文来自织梦

<input onkeypress = "return regInput(this, /^[0-9]*$/, String.fromCharCode(event.keyCode))" dedecms.com

onpaste = "return regInput(this, /^[0-9]*$/, window.clipboardData.getData('Text'))" 织梦好,好织梦

ondrop = "return regInput(this, /^[0-9]*$/, event.dataTransfer.getData('Text'))"

织梦内容管理系统

style="ime-mode:Disabled" dedecms.com

><br>
限2位小数:<xmp style="display:inline"> </xmp> dedecms.com

<input onkeypress = "return regInput(this, /^\d*\.?\d{0,2}$/, String.fromCharCode(event.keyCode))"

织梦内容管理系统

onpaste = "return regInput(this, /^\d*\.?\d{0,2}$/, window.clipboardData.getData('Text'))"

内容来自dedecms

ondrop = "return regInput(this, /^\d*\.?\d{0,2}$/, event.dataTransfer.getData('Text'))" 本文来自织梦

style="ime-mode:Disabled" 织梦好,好织梦

> 如: 123.12<br>

本文来自织梦


日  期:<xmp style="display:inline"> </xmp> 织梦好,好织梦

<input onkeypress = "return regInput(this, /^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,
String.fromCharCode(event.keyCode))"

内容来自dedecms

onpaste = "return regInput(this, /^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,
window.clipboardData.getData('Text'))" dedecms.com

ondrop = "return regInput(this, /^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,
event.dataTransfer.getData('Text'))" dedecms.com

style="ime-mode:Disabled" dedecms.com

> 如: 2002-9-29<br>
任意中文:<xmp style="display:inline"> </xmp> copyright dedecms

<input onkeypress = "return regInput(this, /^$/, String.fromCharCode(event.keyCode))"

织梦好,好织梦

onpaste = "return regInput(this, /^[\u4E00-\u9FA5]*$/, window.clipboardData.getData('Text'))"

看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息