在此代码的按键事件中,TAB键无法在FireFox中工作
$('.Number').keypress(function (event) {
if (!/\d/.test(String.fromCharCode(event.which))) {
$('#error').attr('class', 'errorMessage');
$('#error').text("Enter Only Numbers");
return false;
}
else {
$('#error').attr('class', ' display: none;');
$('#error').text("");
return true;
}
});
答案 0 :(得分:3)
$('.Number').keydown(function (event) {
var keycode = event.which;
if (!/[\d\t\b]/.test(String.fromCharCode(event.which)) || event.shiftKey ) {
$('#error').attr('class', 'errorMessage');
$('#error').text("Enter Only Numbers");
return false;
} else {
$('#error').attr('class', ' display: none;');
$('#error').text("");
return true;
}
});