Similar Threads:
1.Code for validating email address in C# - validate email
Here's a small method for validating email in C#. It may save you some time..
public static bool IsValidEmailAddress(string sEmail)
{
if (sEmail == null)
{
return false;
}
int nFirstAT = sEmail.IndexOf('@');
int nLastAT = sEmail.LastIndexOf('@');
if ( (nFirstAT > 0) && (nLastAT == nFirstAT) &&
(nFirstAT < (sEmail.Length - 1)) )
{
// address is ok regarding the single @ sign
return (Regex.IsMatch(sEmail, @"(\w+)@(\w+)\.(\w+)"));
}
else
{
return false;
}
}
2.dns lookup from .net -- validate email address (domain)
Hi,
I would like to validate an email address from .net. Now before you scream
regular expression I would like something a bit better than this.
I would like to validate the domain, and maybe lookup to see if the domain
has a valid MX record.
can anybody tell me if this is possible using .net and if so point me in the
right direction.
If it is possible then would it also be possible to make sure that I get an
authorative answer and not just an answer from any old server.
many thanks in advance.
martin.
3.Help validating email addresses
I am using a RegularExpressionValidator control on my ASP page, and I have
the ValidationExpression property set to "Internet E-mail Address". The
email address is valiated when the user puts in a email addess in the TextBox.
This works fine until I have multiple email addresses. How can I validate
multiple e-mail addresses seperated by a "," or ";"? The following
ValidationExpression will validate up to 2 email addresses but not anymore:
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*
Any suggestion would be helpful. The number of emails could be infinite,
but I think the max will be 10 at most.
Thanks,
4.Validating Email address with System.Text.RegularExpressions.RegEx
I'm a little confused by this functionality. It doesn't seem to be
behaving like it should.
I am using the following regular expression to validate email
addresses:
"\w+([-+.]\w+)*@\w+([-.]\w+)*\.([a-zA-Z]{2,4})\040*". From what I can
determine it should validate the following rules:
1. BEFORE THE AMPERSAND
A. Must contain at least one alphanumeric character.
B. Can contain a '-', '+', or '.' character but if it does it
must have a alphanumeric character on either side of it.
2. AFTER THE AMPERSAND BUT BEFORE THE '.'
A. Must contain at least one alphanumeric character.
B. Can contain a '-', or '.' character but if it does it must
have a alphanumeric character on either side of it.
3. AFTER THE '.'
A. Must contain at least two alphabetical characters but no more
than 4.
However when I use System.Text.RegularExpressions.RegEx with this
expression and use the IsMatch method and use an email address like
XXXX@XXXXX.COM @ XXXX@XXXXX.COM it returns true as if that was
a valid email address based on the rules.
Doesn't the {2,4} mean that it has to have a minimum of 2 characters
after the '.' character but no more than 4? Also, doesn't the
[a-zA-Z] mean that the characters after the '.' must be alphabetical
only? My tests seem to prove otherwise.
Any help on this would be great...thanks!
5.Validating email addresses using System.Text.RegularExpressions
I'm a little confused by this functionality. It doesn't seem to be
behaving like it should.
I am using the following regular expression to validate email
addresses:
"\w+([-+.]\w+)*@\w+([-.]\w+)*\.([a-zA-Z]{2,4})\040*". From what I can
determine it should validate the following rules:
1. BEFORE THE AMPERSAND
A. Must contain at least one alphanumeric character.
B. Can contain a '-', '+', or '.' character but if it does it
must have a alphanumeric character on either side of it.
2. AFTER THE AMPERSAND BUT BEFORE THE '.'
A. Must contain at least one alphanumeric character.
B. Can contain a '-', or '.' character but if it does it must
have a alphanumeric character on either side of it.
3. AFTER THE '.'
A. Must contain at least two alphabetical characters but no more
than 4.
However when I use System.Text.RegularExpressions.RegEx with this
expression and use the IsMatch method and use an email address like
XXXX@XXXXX.COM @ XXXX@XXXXX.COM it returns true as if that was
a valid email address based on the rules.
Doesn't the {2,4} mean that it has to have a minimum of 2 characters
after the '.' character but no more than 4? Also, doesn't the
[a-zA-Z] mean that the characters after the '.' must be alphabetical
only? My tests seem to prove otherwise.
Any help on this would be great...thanks!
6. Validate email address
7. Validate Email Address Using Regular Expressions
8. validate email address in input textbox