<script language="JavaScript">
<!--
function chkInp(){
var regCh = null;
var regAll = null;
switch(event.srcElement.jinzhi){
case "bin": regCh = /[0-1]/; regAll = /^[0-1]*$/; break;
case "oct": regCh = /[0-7]/; regAll = /^[0-7]*$/; break;
case "hex": regCh = /[0-9a-fA-F]/; regAll = /^[0-9a-fA-F]*$/; break;
default: regCh = /[0-9]/; regAll = /^[0-9]*$/; break;
}
switch(event.type){
case "keypress": event.returnValue = regCh.test(String.fromCharCode(event.keyCode)); break;
case "paste" : event.returnValue = regAll.test(window.clipboardData.getData("text")); break;
case "drop" : event.returnValue = regAll.test(event.dataTransfer.getData("text")); break;
case "blur" : if(regAll.test(event.srcElement.vlaue)) alert("输入非法"); return;
default: break;
}
}
//-->
</script>
<input type="text" jinzhi="" οnkeypress="chkInp()" οnpaste="chkInp()" οndrοp="chkInp()" οnblur="chkInp()"><br>
0123456789<br>
abcdefghijklmnopqrstuvwxyz<br>
ABCDEFGHIJKLMNOPQRSTUVWXYZ<BR>
~!@#$%^&*()_+}{":?><|,.//';[]=-<br>d
<!--
function chkInp(){
var regCh = null;
var regAll = null;
switch(event.srcElement.jinzhi){
case "bin": regCh = /[0-1]/; regAll = /^[0-1]*$/; break;
case "oct": regCh = /[0-7]/; regAll = /^[0-7]*$/; break;
case "hex": regCh = /[0-9a-fA-F]/; regAll = /^[0-9a-fA-F]*$/; break;
default: regCh = /[0-9]/; regAll = /^[0-9]*$/; break;
}
switch(event.type){
case "keypress": event.returnValue = regCh.test(String.fromCharCode(event.keyCode)); break;
case "paste" : event.returnValue = regAll.test(window.clipboardData.getData("text")); break;
case "drop" : event.returnValue = regAll.test(event.dataTransfer.getData("text")); break;
case "blur" : if(regAll.test(event.srcElement.vlaue)) alert("输入非法"); return;
default: break;
}
}
//-->
</script>
<input type="text" jinzhi="" οnkeypress="chkInp()" οnpaste="chkInp()" οndrοp="chkInp()" οnblur="chkInp()"><br>
0123456789<br>
abcdefghijklmnopqrstuvwxyz<br>
ABCDEFGHIJKLMNOPQRSTUVWXYZ<BR>
~!@#$%^&*()_+}{":?><|,.//';[]=-<br>d