You are on page 1of 1

Como validar un Email en un Cuadro de texto(TextBox) usando C-Sharp

MC. Fernando Campos Camacho -UdeO GML-

// Debe agregar la referencia using System.Text.RegularExpressions;

// funcin necesaria private bool EsEmail(string text) { Regex emailregex = new Regex("^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$"); Match mmatch = emailregex.Match(text); if (mmatch.Success) return true; else return false; }

// Ponga el cdigo en un textbox private void textBox3_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { if (EsEmail(textBox3.Text)) { MessageBox.Show("Todo Bien"); } else MessageBox.Show("Email no vlido"); } }

Oct, 2013

You might also like