473,503 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
+ 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:

-->for alphanumeric (allow alphanumeric : a-z,0-9,(symbol))
<asp:textbox onkeypress="if(((event.keyCode>=39)&amp;&amp;(even t.keyCode<=39))){event.returnValue=false;}"
id="txtStfNo" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="440px" Height="60px"></asp:textbox>



<asp:textbox onkeypress="if(((event.keyCode>=39)&amp;&amp;(even t.keyCode<=39))){event.returnValue=false;}"
id="txtccno" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="440px" Height="60px"></asp:textbox>


--->allow numeric only
<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;}"
id="Textbox1" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="152px"></asp:textbox>

---allow symbol only
<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;}"
id="Textbox1" runat="server" Font-Names="Arial" Font-Size="9pt" MaxLength="10" Width="152px"></asp:textbox>



but i want to allow only a-z character and 0-9 number. not allow any symbol
Mar 23 '10 #1
3 5490
CroCrew
564 Recognized Expert Contributor
Look into using AJAX. A FilteredTextBox extender would make life so much easier for you. Here is a link: http://www.asp.net/ajax/ajaxcontrolt...edTextBox.aspx

Happy Coding,
CroCrew~
Mar 24 '10 #2
hidayu1986
7 New Member
this tollbox doesnt have the example which allow only a-z character and 0-9 number. let say i have a textbox. then i want this textbox allow only a-z character and 0-9 number.not allow symbol.how?
Mar 25 '10 #3
CroCrew
564 Recognized Expert Contributor
Yes it does. Use this:

Expand|Select|Wrap|Line Numbers
  1. <ajaxToolkit:FilteredTextBoxExtender 
  2.     ID="ftbe" 
  3.     runat="server"
  4.     TargetControlID="TextBox3"         
  5.     FilterType="UppercaseLetters, LowercaseLetters, Numbers" />
  6.  
Happy Coding,
CroCrew~
Mar 25 '10 #4

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

Similar topics

0
1273
by: Marco Roberto Gonçalves Junior | last post by:
Hi, does anybody know how to insert a UNICODE character in a texbox control by programming? Tks Marco
3
34235
by: Bisley | last post by:
I wish to restrict my textbox to only accepting numbers I have looked the textbox KeyDown event and can inspect KeyEventArgs parameter and interogate which key has been pressed, but I can't work...
2
3067
by: Agnes | last post by:
In my Textbox, User will input a date e.g "2004-12-06" How can I check the curosr position if the user use mouse or arrow to move the cursor position in the textbox ? e.g "2004-12-06" if user move...
2
2900
by: Abra | last post by:
Hi, I would like to allow only some pre-defined characters to be typed in a TextBox (for example only integer numerical, or float numerical, or only a set of letters and so on). How can this be...
10
15883
by: Christopher Lusardi | last post by:
How would I put an end of line character in the second line below? Textbox1.Text = "Hello " Textbox1.Text = Textbox1.Text = "World" Thanks, Chris Lusardi
2
10766
by: si_owen | last post by:
Hi Folks, I am trying to set up some code that will provide a character count for the text entered into a textbox on my form. I am coding in VB.Net using visual studio 2003 - web appliaction. ...
3
1979
by: satyen46113 | last post by:
Hi Can any one help me,I want to store the last character typed in a textbox in a variable,and next time when the user enters another character ,the last chracter gets added to the previous...
4
3787
by: HenrikL | last post by:
Hi! I have textbox that have fixed size in GUI and I need to know how many character I can put into it. For example, the textbox can contain 5 character in GUI and I wan to check if this string...
1
3179
by: hidayu1986 | last post by:
currently i try this code but: -->for alphanumeric(allow alphanumeric : a-z,0-9,(symbol)) <asp:textbox onkeypress="if(((event.keyCode>=39)&amp;&amp;(even t.keyCode<=39))){event.returnValue=false;}"...
4
15285
by: Divyanshi | last post by:
Hello all, I have a textbox, in which i have to perform the following validations 1)first character cannot be blank space 2)characters should not exceed 100 3)if exceeded 100, it should trim...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7323
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...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
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
5576
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,...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
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
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.