here is my code o check whether a string contain any other character than az OR AZ.
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.
Regular expression is ok. Negate predicate:
if (! pattern.IsMatch(txtCustName.Text))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.