AerolineaFrba.Validacion.esTexto C# (CSharp) Method

esTexto() public static method

public static esTexto ( TextBox txtBox, string nombreCampo = "Opcional", System.Boolean mostrarMensaje = false ) : System.Boolean
txtBox System.Windows.Forms.TextBox
nombreCampo string
mostrarMensaje System.Boolean
return System.Boolean
        public static Boolean esTexto(TextBox txtBox , string nombreCampo = "Opcional" , Boolean mostrarMensaje = false)
        {
            String textPattern = "[A-Za-z]";
            System.Text.RegularExpressions.Regex regexTexto = new System.Text.RegularExpressions.Regex(textPattern);
            if (regexTexto.IsMatch(txtBox.Text))
            {
                return true;
            }
            else
            {
                if (mostrarMensaje && !esVacio(txtBox))
                {
                    MessageBox.Show("Para el campo " + nombreCampo + " el criterio debe ser alfanumerico", "Error en el nombre", MessageBoxButtons.OK);
                    return false;
                }
                if(!esVacio(txtBox))
                return false;
            }
            return true;
        }