[jQuery] keypress, keydown + backspace : Firefox, Chrome, IE

[jQuery] keypress, keydown + backspace : Firefox, Chrome, IE


Hello,
I check the keycode, for all input (text) of the page, like this :
$(document).ready(function() {
$("input[type=text]").bind('keypress', function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code != 0 && code != 9 && code != 45 && code != 99) {
.......
}
});
});
But for one specific input, I do this (number only) :
$(document).ready(function() {
$("#HourByWeek").keypress(function(e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code != 8 && code != 0 && (code < 48 || code > 57)) {
return false;
}
if (code != 0) {
......
}
});
I'd like in the first function, place an exception for HourByWeek, how
can I do this ?
With firefox 3.x no problem, bt with Chrome 2.x and IE8, I don't have
any code for the backspace, the backspace is not catched by the
keypress. What is the best way to solve this ?
Thanks,