<input class="j_rate input-text" type="number" onkeydown="$.onlyPositiveNum(event)" style="ime-mode:Disabled" min="3" value="3">
$.extend({
onlyPositiveNum: function (ev) {//input仅允许输入正整数
var e = window.event || ev;
var KeyCode = e.keyCode || e.which;
if (!(KeyCode == 46) && !(KeyCode == 8) && !(KeyCode == 37) && !(KeyCode == 39)) {
if (!((KeyCode >= 48 && KeyCode <= 57) || (KeyCode >= 96 && KeyCode <= 105))) {
if (window.event) {
window.event.returnValue = false;
} else {
e.preventDefault();//for firefox
}
}
}
},
onlyNum: function (ev) {//input仅允许输入正负数(包括小数)
var e = window.event || ev;
var KeyCode = e.keyCode || e.which;
if (!(KeyCode == 46) && !(KeyCode == 8) && !(KeyCode == 37) && !(KeyCode == 39)) {
if (!((KeyCode >= 48 && KeyCode <= 57) || (KeyCode >= 96 && KeyCode <= 105) || (KeyCode == 109) || (KeyCode == 189) || (KeyCode == 190) || (KeyCode == 110))) {
if (window.event) {
window.event.returnValue = false;
} else {
ev.preventDefault();//for firefox
}
}
}
}
})