$(function(){
$("#server_id").bind('keydown', function(e){
DigitInput(e);
});
})
function DigitInput(e) {
var e = e || window.event; //IE、FF下获取事件对象
var cod = e.charCode||e.keyCode; //IE、FF下获取键盘码
if((cod!=8 && cod != 9 && cod != 46 && (cod<37 || cod>40) && (cod<48 || cod>57) && (cod<96 || cod>105))){
notValue(e);
}else{
if(e.shiftKey){
notValue(e);
}
}
function notValue(e){
e.preventDefault ? e.preventDefault() : e.returnValue=false;
}
}
输入框只能输入数字
最新推荐文章于 2024-06-17 16:16:53 发布