<script> function regInput(obj, reg, inputStr) { var docSel = document.selection.createRange() if (docSel.parentElement().tagName != "INPUT") return false oSel = docSel.duplicate() oSel.text = "" var srcRange = obj.createTextRange() 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> <input onkeypress = "return regInput(this, /^條件$/, String.fromCharCode(event.keyCode))" onpaste = "return regInput(this, /^條件$/, window.clipboardData.getData('Text'))" ondrop = "return regInput(this, /^條件$/, event.dataTransfer.getData('Text'))" style="ime-mode:Disabled" > |
||||||||||||||||||||
條件:
|
||||||||||||||||||||
部分中文 | ||||||||||||||||||||
<script language=javascript> |
||||||||||||||||||||
<input onkeypress="return false" onkeydown="setTimeout('checkChinese('+this.value.length+','+this.uniqueID+')', 1)" |
- Oct 23 Fri 2009 17:26
[筆記] Java script - 限制輸入資料類型
全站熱搜
留言列表