<input type="text" class="test">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(".test").keypress(function( b ){
var C = /[0-9\x25\x27\x24\x23]/;
var a = b.which;
var c = String.fromCharCode(a);
return !!(a==0||a==8||a==9||a==13||c.match(C));
});
</script>