Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to validate the textbox at client side and it must contain any alphabet or number or _ or -. So to do that I wrote like this

ValidationExpression="^[0-9a-zA-Z_\-]$"


but Its not working as I want...




PS : not good in REGEX :(
Posted

This is the regex you want:
^[0-9a-zA-Z_\-]+$

Notice the "+". That means "1 or more of the preceeding". You might want to use "*" instead, which means "0 or more of the preceeding" (that would match an empty string).
 
Share this answer
 
I recommend: http://www.ultrapico.com/Expresso.htm[^]

It's free too!

Nick
 
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