473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

code for entering only alphabets in textboxes

pls give me code for entering only alphabets in textboxes
May 17 '07 #1
3 6367
mrhoo
428 256MB
The only easy one is the English alphabet- /[^a-z]$/.i.test(val)

inputelement.onkeyup=function(e){
e=e || window.event;
var who=(window.event)? e.srcElement: e.target;
var val=who.value;
while(val && /[^a-z]$/.i.test(val)) val=val.slice(0,-1);
who.value=val;
}

for non-english alphabets you need to replace a-z in the expression
with the unicode range or ranges of the character sets.
May 17 '07 #2
pbmods
5,821 Expert 4TB
Or use replace...

Expand|Select|Wrap|Line Numbers
  1. <input type="text" onkeyup="validateR(this, '')" ruleset="[^a-z]" />
  2.  
Expand|Select|Wrap|Line Numbers
  1. function validateR(element, replacement) {
  2.     //  IE
  3.     if(! element)
  4.         element = window.event.srcElement;
  5.  
  6.     element.value = element.value.replace(new RegExp(element.getAttribute('ruleset'), 'gi'), replacement);
  7. }
  8.  
I'm not sure if the replacement argument will be valid in IE. You might have to use a second custom attribute in the INPUT tag or else use a global variable.
May 17 '07 #3
dmjpro
2,476 2GB
Okk .... using REGEXPRESSIONs is good.

there is another fantastic way to do it.....

<input type = text onkeypress = test()>

now test method is given below....

function test()
{
if(no_the_key_codes_r_not_alphabate) return false;
else return true;
}


...... i think u got my point of view.
best of luck with my code.

kind regards.
dmjpro.
May 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Stephen | last post by:
I was wondering if someone could please help me with an array I'd like to create in an asp.net page. I have to design an array which stores the values of addresses manually entered into textboxes...
12
by: MeNotHome | last post by:
I need to be able to open up a URL and enter some data, press a button and then wait for the page to load and then click a check box and press another button. Is there a good example on the...
1
by: reidarT | last post by:
When I add textboxes and labels onto a form from the toolbar, how do I easily move from Name to Name to give them proper names and after that remove the Text from Text without clicking on thr...
3
by: rayapatilavakumar | last post by:
Hi all, i am doing one ASP.Net/C#.Net project in that i have designed one form,in that form i have 2 textboxes for username and password and one check box and one button.after entering the data into...
5
by: salo | last post by:
hi... can anybody help me for displaying only alphabets in textboxes in visual studio 2005 i gave in validation expression for regular expression validation...... but still im not getting ....if i...
1
by: rajeevs | last post by:
Hi I have posted earlier about the same but only one reply thanks but i dont know how to do that. Please help again i will explain what i need to do in ms access by using a query i want to trim...
2
by: robertns5411 | last post by:
I have two questions: 1) Say I have a form bound to a table. Assume the user is entering data into a new record at the bottom of the form. Now, suppose the user clicks a button on the form...
17
nitindel
by: nitindel | last post by:
Hi All, I have a text box and want to validate it like this: I want to enter Numerics or alphanumerics in the text box but not Alphabets alone.If Alphabets alone entered then...
1
by: sury | last post by:
I want to split a word into individual alphabets and substitute a word for each of the alphabets in c#. example: If the word entered is LATE, the output wud be L:London A :Apple T:Tom E:Egg
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.