<form method="get">
<textarea rows="10" cols="30" style="ime-mode:disabled"></textarea>
</form>
<script>
window.onload=function(){
var fm=document.forms[0];
var text=fm.elements[0];
text.onkeypress=function(evt){
var code=getCharcode(evt);
txt=String.fromCharCode(code);
if(!/\d/g.test(txt) && code>8){
alert("只能输入数字")
getdefalut(evt)
}
}
function getCharcode(e){
var e=e||window.event;
return e.charCode || e.keyCode
}
function getdefalut(e){
var e=e||window.event;
if(e.preventDefault){
e.preventDefault();
}else if(e.returnVlaue){
e.returnVlaue=false;
}
}
}
</script>