Hi! i want to validate a textbox, where the email is introduces. First i check if the email is too short, and it works, then i try to check if it ends with @yahoo.com or @gmail.com but it doesn't work fine. I guess it's a problem with Substring. Any help? thks.
private void emailTxt_Validating(object sender, CancelEventArgs e)
{
string mesaj = null;
string email = emailTxt.Text;
int lungime = email.Length;
if (lungime < 11)
{
mesaj = "E-mail prea scurt!";
this.errorProvider1.SetError(this.emailTxt, mesaj);
}
else
{
string text = email.Substring(lungime - 12, 10);
if (text != "@yahoo.com" || text != "@gmail.com")
{
this.errorProvider1.SetError(this.emailTxt, mesaj);
}
}
}