Introduction:
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.
Description:
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, Asp.net. Now I will explain how to allow only alphabets in textbox 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, Asp.net. Now I will explain how to allow only alphabets in textbox using JQuery.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Allow
only alphabets in textbox using jquery</title>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function ()
{
$('#txtNumeric').keydown(function (e) {
if (e.shiftKey || e.ctrlKey || e.altKey) {
e.preventDefault();
} else {
var key = e.keyCode;
if (!((key == 8) || (key == 32) || (key == 46) || (key
>= 35 && key <= 40) || (key >= 65 && key <= 90)))
{
e.preventDefault();
}
}
});
});
</script>
</head>
<body>
<div>
<b>Enter
Text:</b><input type="text"
id="txtNumeric"
/>
</div>
</body>
</html>
|
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 Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
19 comments :
I think this live demo is not working properly. Please check it.
not work ,, plzzz check it
thanks. i updated live demo. Please check it once and let me know if any problem is exists.
Thank you , it is working
I want to write a character using shift key its not working..
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......
nice working my project in helpful
Thank you so much
Thank you so much. I was trying to figure this out for hours. Delete "e.shiftKey ||" for typing Capital letters
how to do in asp:textbox?
thanqu sir for give a collection of gud n vry useful programes of javascript n Jquery
Ur all apps are nice,clear and helpful...............
Keep it up.
thank you
Hi
It useful
But one problem When I Caps On it not working.
how to make in multiple text box?
how to apply this same code for multiple input box?
When i press tab key after entering the characters in textbox tab key is not working
i wanna in textbox only write alpha letter
any one send code
i wanna in textbox only write alpha letter
any one send code
Good but, it's not working with Shift key. I want enter my name with first letter capital but it's not working.
Note: Only a member of this blog may post a comment.