Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29769

How can I make a textbox only accept a valid email? [duplicate]

$
0
0

This question already has an answer here:

I would like my textbox to check if the email that is entered into the textbox is valid.

So far I have got:

if (!this.txtEmail.Text.Contains('@') || !this.txtEmail.Text.Contains('.')) 
{ 
    MessageBox.Show("Please Enter A Valid Email", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error); 
}

But this only tests if it has a '@' and a '.' in it.

Is there a way to make it check to see if it has .com etc. and only one '@'?


Viewing all articles
Browse latest Browse all 29769

Trending Articles