Question: So, I have to code for a method that validates whether the string that saves name contains alphabets only, no numbers. The validation of textbox values should apply when the user enters by textchanged event before submitting the form and display an error message of red color on the label. My code works but the problem is when I enter a numeric number in text box, the label displays error which stays even when I delete the text box value and enter the alphabetic string. 

I have declared a method which assign error string to label, and is called if regular expression does not match with the text box input, during text changed event. 

```
public void Validator()
{
    Calculate_Salary.Enabled = false;
    label4.Text = "Please enter only alphabetical letters";
}

private void _Name_TextChanged(object sender, EventArgs e)
{
    Regex pattern = new Regex("/^[A-Za-z]+$/");
    string name = _Name.Text;
    if (pattern.IsMatch(name))
    {
        Calculate_Salary.Enabled = true;
        label4.Text = "";

    }
    else
    {
        Validator();
    }
}     

```

![GUI](https://i.stack.imgur.com/lutHp.jpg)

Answer: 
Your `Regex` comparison is wrong try this code:

```
public void Validator()
{
    Calculate_Salary.Enabled = false;
    label4.Text = "Please enter only alphabetical letters";
}

private void _Name_TextChanged(object sender, EventArgs e)
{
    label4.Text = "";
    string name = _Name.Text;
    if (Regex.IsMatch(name, @"^[a-zA-Z]+$"))
        Calculate_Salary.Enabled = true;
    else
        Validator();
}

```
I changed the validation code. It seems to work now. 

```
private void _Name_TextChanged(object sender, EventArgs e)
{
    label4.Text = string.Empty;

    string name = _Name.Text;
    if (Regex.IsMatch(_Name.Text, "^[a-zA-Z]+$") || _Name.Text=="")
    {
        Calculate_Salary.Enabled = true;
    }
    else
    {
        Calculate_Salary.Enabled = false;
        label4.Text = Validator();
    }
}

```