/// <summary> /// Validates input lastName. If unsuccessful, shows the corresponding errorLabel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lastNameTextBox_Validating(object sender, CancelEventArgs e) { if (lastNameTextBox.Text.Length < 1) { lastNameErrorLabel.Text = "Required"; lastNameErrorLabel.Visible = true; lastNameTextBox.BackColor = SystemColors.Control; return; } if (handler.IsValidLastName(lastNameTextBox.Text)) { lastNameErrorLabel.Visible = false; lastNameTextBox.BackColor = SystemColors.Window; } else { lastNameErrorLabel.Visible = true; lastNameErrorLabel.Text = "Invalid Last name, only letters please"; lastNameTextBox.BackColor = SystemColors.Control; } }