input输入框限制只能输入数字
js:
function onlyNumber(event){
var keyCode = event.keyCode;
if((keyCode<48&&keyCode>8) ||(keyCode>57&&keyCode<96) ||keyCode<8||keyCode>105){//8为删除键96到106为小键盘
window.event.returnValue= false;
}
}
$(
function
(){
$(
"#numberbox"
).keydown(onlyNumber);
});
html:
<
input
type
=
"text"
id
=
"numberbox"
/>