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 - Allow Only Alphabets in Textbox using JavaScript

Apr 22, 2013

Here I will show how to use JQuery to allow only alphabets in textbox or how to make textbox to allow only alphabets using JQuery.

In previous posts I explained
jQuery Allow only numbers in textbox, jQuery disable cut copy and paste options in textbox, jQuery Create Rounded Corners Textbox, jQuery slideUp, slideDown and slideToggle Example and many articles relating to JQuery, JavaScript, Now I will explain how to allow only alphabets in textbox using JQuery.

To allow only alphabets in textbox using JQuery we need to write the following code

<html xmlns="">
<title>Allow only alphabets in textbox using jquery</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 == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
<b>Enter Text:</b><input type="text" id="txtNumeric" />
Live Demo

To check live demo try to enter characters in below textbox

Enter Text:

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...

I think this live demo is not working properly. Please check it.

Anonymous said...

not work ,, plzzz check it

Suresh Dasari said...

thanks. i updated live demo. Please check it once and let me know if any problem is exists.

Anonymous said...

Thank you , it is working

Unknown said...

I want to write a character using shift key its not working..

Neeraj said...

i think this not work properly when i enter input as character then enter but when i press shift key then press any alphabetic character then not work......

Irtekaz Ahmed Khan said...

nice working my project in helpful

Atul shukla said...

Thank you so much

Unknown said...

Thank you so much. I was trying to figure this out for hours. Delete "e.shiftKey ||" for typing Capital letters

Anonymous said...

how to do in asp:textbox?

Unknown said...

thanqu sir for give a collection of gud n vry useful programes of javascript n Jquery

Anonymous said...

Ur all apps are nice,clear and helpful...............
Keep it up.
thank you

Harsh Nag Bollu said...

It useful
But one problem When I Caps On it not working.

Unknown said...

how to make in multiple text box?

Unknown said...

how to apply this same code for multiple input box?

Unknown said...

When i press tab key after entering the characters in textbox tab key is not working

Unknown said...

i wanna in textbox only write alpha letter
any one send code

Unknown said...

i wanna in textbox only write alpha letter
any one send code

Shivraj Singh said...

Good but, it's not working with Shift key. I want enter my name with first letter capital but it's not working.

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.