473,473 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to allow only character (a-z) and number(0-9) only in the textbox?

7 New Member
currently i try this code but:
Expand|Select|Wrap|Line Numbers
  1. -->for alphanumeric(allow alphanumeric : a-z,0-9,(symbol))
  2. <asp:textbox onkeypress="if(((event.keyCode>=39)&amp;&amp;(even t.keyCode<=39))){event.returnValue=false;}"
  3. id="txtStfNo" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="440px" Height="60px"></asp:textbox>
  4.  
  5.  
  6.  
  7. <asp:textbox onkeypress="if(((event.keyCode>=39)&amp;&amp;(even t.keyCode<=39))){event.returnValue=false;}"
  8. id="txtccno" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="440px" Height="60px"></asp:textbox>
  9.  
  10.  
  11. --->allow numeric only
  12. <asp:textbox onkeypress="if(((event.keyCode>=32)&amp;&amp;(even t.keyCode<=47))||((event.keyCode>=58)&amp;&amp;(ev ent.keyCode<=254))){event.returnValue=false;}"
  13. id="Textbox1" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="152px"></asp:textbox>
  14.  
  15. ---allow symbol only
  16. <asp:textbox onkeypress="if(((event.keyCode>=48)&amp;&amp;(even t.keyCode<=57))||((event.keyCode>=65)&amp;&amp;(ev ent.keyCode<=90))||((event.keyCode>=97)&amp;&amp;( event.keyCode<=122)) ){event.returnValue=false;}"
  17. id="Textbox1" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="152px"></asp:textbox>
  18.  
  19.  
but i want to allow only a-z character and 0-9 number into the textbox. not allow any symbol
Mar 23 '10 #1
1 3178
jkmyoung
2,057 Recognized Expert Top Contributor
event.returnValue=false;
I thought you were supposed to return true, but I could be mistaken.

I suggest writing external functions to make the code cleaner. Then you could have those functions call other functions, like IsDigit(), IsLetter(), IsSymbol(), etc.

Also, you've posted in the wrong forum.
Mar 23 '10 #2

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

Similar topics

2
by: Nick | last post by:
In VS 2003 and VS 2005 beta 2 I am trying to write a simple program. It has a datagrid and a textbox along with a menubar. There is a command in the menu bar which is "Run Query" and has the...
16
by: Ramsin Savra | last post by:
Hi, What do you suggest to do if I want to do a search in TextBox ? I know that using RichTextBox, we could have Find method to search for a specific word or information but I was wonder if...
2
by: Dean L. Howen | last post by:
How to show special character (example anpha, beta, gama...) in TextBox/RichEditTextBox? Thanks
4
by: Peteroid | last post by:
I want to use a Textbox to allow the user to input a floating point number. In my case it will always be non-negative. Is there an easy way to do this, or possibly a link to some sample code that...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: Peter | last post by:
I hate using the mask edit conrol so I created these two function to format my phone numbers. Is there a way to consolidate these two functions into one? In this example say the textbox you...
2
Ajm113
by: Ajm113 | last post by:
I want to have a textbox that only allows Numbers, Periods, Spaces, and Minuses in it using C#. How is this accomplished? I already have the code set up like this: private void...
1
by: Luzuko | last post by:
I would like to know how can i restrict textbox input in VB.net using code instead of VB.net controls. e.g If i want a user to type numbers only in a textbox(ID number textbox), how can i make...
1
by: phpmel | last post by:
Hi all, I am have no idea at all how to do this. I want a textbox where the first character in the box is a 'M'.The user can see this but cannot change it. Now, i want to allow them to enter 5...
0
by: =?Utf-8?B?R3JlZw==?= | last post by:
I am new to C# and Web-Development, so I am not 100% sure how I should word my question. So, here goes my try. I've inherited a web application that was developed using C#. It appears to be an...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.