这里以数字框为例,只允许输入数字(输入限制,粘帖限制,输入法限制)
<input type="text" name="Number"
onKeyPress="Numbers()"
onPaste="return false"
style= "ime-mode:disabled" >
<script>
function Numbers(){
var key = window.event.keyCode;
if(key<48 || key>57){
window.event.keyCode = 0;
}
}
var key = window.event.keyCode;
if(key<48 || key>57){
window.event.keyCode = 0;
}
}
</script>
转载于:https://blog.51cto.com/xieyu/50597