email address verification

How to verify email address ? While submitting form.

[59 byte] By [officexpboy] at [2007-12-25]
# 1

you would do some Regex on it, regular expressions, checking the field of the email address. If Regex returns true then email address is valid so continue, otherwise its false and there is an error so notify the user.



Regex theEmailValidator = new Regex(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3} \.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)"); //"(?<user>[^@]+)@(?<host>.+)");

Match emailMatch = theEmailValidator.Match(EmailAddressHere);
if (!emailMatch.Success)
{
return false;
}
else
{
return true;
}

There are a few Regex patterns, this one is what I use and works well

ahmedilyas at 2007-8-31 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 2

Well, you have any another way, that's probably more neat & visual.

if you are working with Visual Web Developer, Use Reguler Expression Validation control, drag it next to the email text box, in its properties "ExpressiontoValidate" select "Internet Email Address" & in property "ControltoValidate" select name of the textbox which you use for email input. In its Error property write any message you want to display in case of Wrong email entery, this will work when user will hit "Submit" button on your webform.

YasirImran at 2007-8-31 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...
# 3

Thx for your reply.

What i'm looking is -

Email

  • Syntax
  • domain Validation
  • mail server and the recipient Validation
officexpboy at 2007-8-31 > top of Msdn Tech,.NET Development,ASMX Web Services and XML Serialization...

.NET Development

Site Classified