/// <summary> /// Validates Ssn. If it's not valid, it shows an error message in the ssnErrorLabel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ssnTextBox_Validating(object sender, CancelEventArgs e) { if (ssnTextBox.Text.Length < 1) { ssnErrorLabel.Text = "Required"; ssnErrorLabel.Visible = true; ssnTextBox.BackColor = SystemColors.Control; } if (handler.IsValidSsn(ssnTextBox.Text, out string errorMsg)) { ssnErrorLabel.Visible = false; ssnTextBox.BackColor = SystemColors.Window; } else { ssnErrorLabel.Visible = true; ssnErrorLabel.Text = errorMsg; ssnTextBox.BackColor = SystemColors.Control; } }