private void NameTextBox_TextChanged(object sender, EventArgs e) { if (RegexValidation.IsNameValid(NameTextBox.Text)) { nameErrorProvider.SetError(NameTextBox, String.Empty); } else { nameErrorProvider.SetError(NameTextBox, "Invalid name format."); } }