Any email validation functions?

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

Does anyone have any VB.NET functions which validate an email address?
Could you post it? I would like it to do as much as the regular expression
validator if possible.

Thanks in advance!
 
there should already be a email validator regex function in the validators
to test for this (at least there is in asp.net) but here you go...

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

regex function to validate all email addresses
 
Thanks, but I'm looking for a VB.NET version. Do you know of one?

Brian Henry said:
there should already be a email validator regex function in the validators
to test for this (at least there is in asp.net) but here you go...

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

regex function to validate all email addresses

VB Programmer said:
Does anyone have any VB.NET functions which validate an email address?
Could you post it? I would like it to do as much as the regular
expression
validator if possible.

Thanks in advance!
 
Oh... I got it! Here's one I'd like to share. If anyone has any better one
please let me know.

Private Function EmailIsValid(ByVal strEmailAddress As String) As
Boolean
Return Regex.IsMatch(strEmailAddress,
"^([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})(\]?)$")
End Function

Thanks!


VB Programmer said:
Thanks, but I'm looking for a VB.NET version. Do you know of one?

Brian Henry said:
there should already be a email validator regex function in the validators
to test for this (at least there is in asp.net) but here you go...

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

regex function to validate all email addresses

VB Programmer said:
Does anyone have any VB.NET functions which validate an email address?
Could you post it? I would like it to do as much as the regular
expression
validator if possible.

Thanks in advance!
 
VB said:
Oh... I got it! Here's one I'd like to share. If anyone has any
better one please let me know.

Private Function EmailIsValid(ByVal strEmailAddress As String) As
Boolean
Return Regex.IsMatch(strEmailAddress,
"^([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})(\]?)$")
End Function

Unfortunately, this code will refuse mails from the "museum" domain.

Replace the {2,4} with {2,6} to allow for this domain as well.
 
Thanks! Great catch!

Jos said:
VB said:
Oh... I got it! Here's one I'd like to share. If anyone has any
better one please let me know.

Private Function EmailIsValid(ByVal strEmailAddress As String) As
Boolean
Return Regex.IsMatch(strEmailAddress,
"^([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})(\]?)$")
End Function

Unfortunately, this code will refuse mails from the "museum" domain.

Replace the {2,4} with {2,6} to allow for this domain as well.
 
I don't get anything of what is happening in the function!!! How does this
validate Email addresses and why not the museum domain??
Confused & (probably) stupid.

VB Programmer said:
Thanks! Great catch!

"^([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})(\]?)$")
End Function

Unfortunately, this code will refuse mails from the "museum" domain.

Replace the {2,4} with {2,6} to allow for this domain as well.
 
Never mind, just saw Jay's post.
Vince said:
I don't get anything of what is happening in the function!!! How does this
validate Email addresses and why not the museum domain??
Confused & (probably) stupid.

VB Programmer said:
Thanks! Great catch!
"^([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})(\]?)$")
End Function

Unfortunately, this code will refuse mails from the "museum" domain.

Replace the {2,4} with {2,6} to allow for this domain as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top