Allow only numeric input in textbox using jQuery

How to allow only numeric (0-9) in HTML inputbox using jQuery?

$(".allownumericwithdecimal").on("keypress keyup blur", function (event) {
     //this.value = this.value.replace(/[^0-9\.]/g,'');
     $(this).val($(this).val().replace(/[^0-9\.]/g, ''));
     if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
         event.preventDefault();
     }
 });

 $(".allownumericwithoutdecimal").on("keypress keyup blur", function (event) {
     $(this).val($(this).val().replace(/[^\d].+/, ""));
     if ((event.which < 48 || event.which > 57)) {
         event.preventDefault();
     }
 });
Allow only numeric input in textbox using jQuery Allow only numeric input in textbox using jQuery Reviewed by Bhaumik Patel on 7:43 PM Rating: 5