Allow only numbers in textbox jquery on keypress

If you required to add allow only numbers in textbox jquery on keypress or jquery based validation for your HTML Form textbox such as textbox should accept only numbers values on keypress event. therefor you can also use keyup or keypress event to allow only numeric values in textbox using jquery.

jquery allow only numbers on keypress Example

i will use keyCode for prevent to add data string values. i will also accept only numbers in HTML textbox using jquery.

How to allow only numeric (0-9) in HTML inputbox using jQuery?
I want to write very easy and complete example therefor you can understand how it is working this example. you can also check simple demo. i will also more example link to bottom therefor you can check it. let’ see following the complete example:

ALSO Read: JQuery Allow Only Numbers Input in Textbox

JQuery – Allow only numeric values (numbers) in Textbox

index.html




  JQuery - Allow only numeric values (numbers) in Textbox - pakainfo.com
  


   

JQuery - Allow only numeric values (numbers) in Textbox - pakainfo.com

Inline: Way




Short and sweet Solution

  $('#number_only').bind('keyup paste', function(){
        this.value = this.value.replace(/[^0-9]/g, '');
  });

textbox should accept only numbers using jquery

Leave a Comment