Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
heyy..

I want a regular expression for allow only alphanumeric,space and hypen in a textbox

Any regular expressions??
Posted

You should be able to find it in this site. http://regexlib.com/[^]
 
Share this answer
 
Try this
^[A-Za-z0-9- ]+$

Regards.. :laugh:
 
Share this answer
 
Comments
aravindnass 9-Jul-13 3:42am    
thanks...
Thanks7872 9-Jul-13 3:43am    
You are welcome...:)
Brian A Stephens 9-Jul-13 11:01am    
To match a dash (hyphen) in a character class, the dash needs to be either first or last, or be escaped. The syntax you have given may work inadvertently, but is not correct because of the space at the end.
XML
try this one ,.. without regular expressions to restrict input text...

<asp:TextBox ID="txtSearch" runat="server" ></asp:TextBox>






 <ajaxToolkit:FilteredTextBoxExtender ID="fteSearch" runat="server" TargetControlID="txtSearch" FilterMode="InvalidChars"
InvalidChars=";|~!@#$%^*<>/\{}:';/*+_~`[]=&quot;">
 </ajaxToolkit:FilteredTextBoxExtender>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900