I have a textbox field. I want to put a validator for the textbox that if it contain any special character in name then need to throw exception. Below is the code I used but not working. Please let me know where I am doing wrong or provide any specific code
string input = txtName.Text;
Match match = Regex.Match(input, @"^[^/\\()~!#$%|<>:{}+?^&*""]");
if (!match.Success)
{
lblMessage.Text = txtName.Text + " detected! " + match.Value + " Prohibited characters are: ^, /, , (, ), ~, !, #, $, %, |, <, >, :, ,, {, }, +, ?, &, *, \", [, ] and cannot be saved.";
}