Restrict input to number only on pasting
问题 I have an input filed with a class called restrict-numbers which i want to restrict the entered characters to only accept numbers, i used the following code which is great but the problem that i want to make the same restriction works with pasting in the input filed without totally disabling pasting: function input_only_numbers(){ $("input[type=text]").each(function(){ if( $(this).hasClass("restrict-numbers") ){ $(this).keydown(function(event) { if ( event.keyCode == 46 || event.keyCode == 8