7
Answers

How to Allow letters,numbers,some special characters only?

Raja

Raja

8y
281
1
i want to allow letters,numbers and some special characters in textbox(,.\-_)this special characters only or throw error message how to do it.
Answers (7)
0
Midhun T P

Midhun T P

NA 19.7k 281.1k 8y
Hi,
Please try below expression -
Regex regex = new Regex(@"^[a-zA-Z0-9 ,.\\-_]*$");
if (!regex.Match(Textbox1.Text).Success)
{
//does not match your pattern
}
Accepted
1
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.4k 8y
Hi,
 
Based on your requirement you can use the following Regex Code.
  1. Regex regex = new Regex(@"[^0-9\\(,._)\-\a-zA-Z]");  
Please check this demo :
 
http://regexr.com/3ebkn
1
Bikesh Srivastava

Bikesh Srivastava

NA 19.8k 835k 8y
Hi,
you need to use Regex.
  1. ^(?=.*[a-zA-Z\d].*)[a-zA-Z\d!@#$%&*]{7,}$
1
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.4k 8y
Hi,
 
You can use the code regex inside the textBox1_TextChanged event in Textbox Control In Asp.net.
1
Rajeesh Menoth

Rajeesh Menoth

NA 24.7k 629.4k 8y
Hi,
Please check the following reference :
http://stackoverflow.com/questions/12607087/only-allow-specific-characters-in-textbox
0
Raja

Raja

NA 1.7k 45.4k 8y
<h4><a data-userid="2a6dc5" href="http://www.c-sharpcorner.com/members/rajeesh-menoth">Rajeesh Menoth</a></h4><div><h4><a data-userid="895c53" href="http://www.c-sharpcorner.com/members/bikesh-srivastava2">Bikesh Srivastava</a></h4><div><h4><a data-userid="9088f9" href="http://www.c-sharpcorner.com/members/midhun-tp">Midhun T P</a></h4>Thanks To All..</div></div>
0
Raja

Raja

NA 1.7k 45.4k 8y
how to use code behind.without using scripting