Regular expression is ok. Negate predicate:
if (! pattern.IsMatch(txtCustName.Text))
Pergunta
here is my code o check whether a string contain any other character than a-z OR A-Z.
Regex pattern = new Regex("^[a-zA-Z]+$");
if (pattern.IsMatch(txtCustName.Text))
{
MessageBox.Show("Name contains some Invalid Characters");
txtCustName.Focus();
}
It still showing error msg even I'm typing he correct string.
Solução
Regular expression is ok. Negate predicate:
if (! pattern.IsMatch(txtCustName.Text))