private void SecurityNumtextBox2_Leave(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(SecurityNumtextBox2.Text)) { SecurityNumerrorProvider.SetError(this.SecurityNumtextBox2, "Enter a valid security number"); } else { SecurityNumerrorProvider.Clear(); } }
private void SecurityNumtextBox2_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar)) { e.Handled = true; SecurityNumerrorProvider.SetError(this.SecurityNumtextBox2, "Only Numeric value is valid as Amount"); } else if (SecurityNumtextBox2.Text.Length != 4) { SecurityNumerrorProvider.SetError(this.SecurityNumtextBox2, "Enter a valid security number"); } else { SecurityNumerrorProvider.Clear(); } }