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.

Read Also:  Laravel Database Eloquent Unions Query

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.

jquery Count Number of characters in string input

First Of all add textbox control in  your html.

Read Also:  Allow only numbers in textbox jquery on keypress

<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

Read Also:  Select / Deselect all checkboxes using jQuery

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.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  laravel clear cache PHP Artisan Tutorials
  2. Read Also:  how to remove query string from url?
  3. Read Also:  ng-init Multiple Values using Angular Example
  4. Read Also:  Bootstrap Modal popup multiple File Upload using AJAX
  5. Read Also:  Laravel Multiple Database Connections Step By Step
  6. Read Also:  How to allow only numbers in Textbox using Jquery?
  7. Read Also:  Jquery Restrict only 10 numbers input in textbox
  8. Read Also:  Angular 6 Routing Tutorial with Examples
  9. Read Also:  Laravel MySQL Database Relationship Queries
  10. Read Also:  jQuery An Animated Scroll To Top Button