I'm using this function to only allow numbers in a text input.
$('input').bind('keydown', function(e) {
var key = e.charCode || e.keyCode || 0;
return (
key == 8 ||
key == 9 ||
key == 46 ||
(key >= 37 && key <= 40) ||
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105));
});
How would I also allow copy and paste? I've tried adding keycode 17 for control but it still doesn't work.
Is there something special you have to do for key combinations?
Thanks