修正了拖拽文本进输入框问题 2011.11.14
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>仅限正整数输入</title>
</head>
<body>
<script>
//void function (window,undefined){
window.onload = function() {
var doc = document,list = doc.getElementsByTagName('input');
availableNumberInput(list);
}
function availableNumberInput(inputs) {
var len = inputs.length,i,reg = /^(8|9|4[8-9]|5[0-7]|9[6-9]|10[0-5])$/ig;
document.onmousedown=function(){
try{
document.selection.empty()
}catch(e){
getSelection().removeAllRanges()
}
}
for (i = len; i > 0; (inputs[--i].onkeydown = function(e) {
e = window.event || e;
var target = e.srcElement || e.target,code = e.charCode || e.keyCode;
reg.lastIndex = 0;
if (!reg.test(code) || e.shiftKey) {
return false;
}
target.value === '0' && (target.value = '');
},inputs[i].oncontextmenu = function() {
return false;
}),inputs[i].style.imeMode = 'disabled') {
}
}
//}(window);
</script>
拖个文字进输入框看看<br/>
<input type="text"/><br/>
<input type="text"/><br/>
<input type="text"/>
</body>
</html>