JQuery Allow Only Numbers Input in Textbox

JQuery Allow Only Numbers Input in Textbox

Today, We want to share with you JQuery Allow Only Numbers Input in Textbox.
In this post we will show you Allow only numeric input in textbox using jQuery, hear for Enter Only Numbers and Decimal Values Using jQuery we will give you demo and example for implement.In this post, we will learn about jQuery – Allow Only Numbers (Numerics) in Textbox with an example.

Now in this post, I will explain how to Allow Only Numbers in Textbox using JQuery with appropriate example. Many a times you want only numeric value in textbox like Count of something, Phone number ,Computer Port etc. In such a situation you can use Jquery to alllow only numeric value by writting below code.

Also Read This ๐Ÿ‘‰   Laravel Encryption Decryption using Crypt class

jquery Count Number of characters in string input

Free Live Chat for Any Issue

First Of all add textbox control inย  your html.

<input type="text" id="txtOnlyNumber">

Now write below lines in JavaScript file or include it in script section of above html file.

$(function () {
$('#txtOnlyNumber').keydown(function (e) {
if (e.shiftKey || e.ctrlKey || e.altKey) {
} else {
var key = e.keyCode;
if (!((key == 8) || (key == 46) || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) {

Allow Only Numbers in Textbox using JQuery

Also Read This ๐Ÿ‘‰   Jquery Restrict only 10 numbers input in textbox

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about How to allow only numeric values ( numbers ) in a TextBox using jQuery.I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโ€™t forget to share.