aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Restrict to Allow Only Numbers in Textbox in

Nov 24, 2012

Here I will explain how to allow only numbers or numeric characters in textbox using
JQuery in

In previous posts I explained jQuery Autocomplete textbox with images, jQuery lightbox slideshow, jQuery Create Rounded Corners Textbox,
jQuery slideUp, slideDown and slideToggle Example, Password strength jquery plugin examples and many articles relating to JQuery, Now I will explain how to allow only numbers or numeric characters in textbox using JQuery in

To restrict user to enter only numbers in textbox we need to write the following code

<html xmlns="">
<head runat="server">
<title>jQuery allow only numbers or numeric characters in textbox</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(function() {
$('#txtNumeric').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))) {
<form id="form1" runat="server">
<asp:TextBox ID="txtNumeric" runat="server"/>

Live Demo

To check Live demo try to enter characters in below textbox

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

Able to enter charecter

rahul sodagar said...

character enter ho rahe he..

Anonymous said...

fail, it let pass &* and others..

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.