/// <summary> /// This method invokes a method having a regular expression that validates the format of the entered employee designation. /// </summary> /// <param name="sender">The control that fired the event</param> /// <param name="e">The arguments associated with the fired event.</param> private void designation_Validating(object sender, CancelEventArgs e) { string textInput = designation.Text.TrimStart().TrimEnd(); if (string.IsNullOrEmpty(textInput)) { MessageBox.Show("No designation has been entered", "Salary Slip Application", MessageBoxButtons.OK, MessageBoxIcon.Error); designation.Focus(); } else if (!(RegularExpressionValidator.IsValidDesignation(textInput))) { MessageBox.Show("The entered designation is not in proper format", "Salary Slip Application", MessageBoxButtons.OK, MessageBoxIcon.Error); designation.Focus(); } }