/// <summary> /// Validates input firstName. If unsuccessful, shows the corresponding errorLabel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void firstNameTextBox_Validating(object sender, CancelEventArgs e) { if (firstNameTextBox.Text.Length < 1) { firstNameErrorLabel.Text = "Required"; firstNameErrorLabel.Visible = true; firstNameTextBox.BackColor = SystemColors.Control; return; } if (handler.IsValidFirstName(firstNameTextBox.Text)) { firstNameErrorLabel.Visible = false; firstNameTextBox.BackColor = SystemColors.Window; } else { firstNameErrorLabel.Visible = true; firstNameErrorLabel.Text = "Invalid First name, only letters and '-' please"; firstNameTextBox.BackColor = SystemColors.Control; } }