Email Validation

K

Kiran B.

Hi, how can I validate the fomat for valid email and the most important is
if that email is real working email...sort of checking mx record? How can i
do this in asp.net

Thanks in advance....

KB
 
V

vMike

Kiran B. said:
Hi, how can I validate the fomat for valid email and the most important is
if that email is real working email...sort of checking mx record? How can i
do this in asp.net

Thanks in advance....

KB
I use the following. I am sure there are other ways but it works for me.
<asp:RegularExpressionValidator id="RequiredEmail1" runat="server"
ControlToValidate="Email1"
InitialValue=""

ValidationExpression="^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|
(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
Display="Static"
Font-Name="verdana" Font-Size="10pt">
* valid e-mail address required
</asp:RegularExpressionValidator>
<asp:CustomValidator id="CustomValidator1" runat="server"
ControlToValidate="Email1"
OnServerValidate="ServerValidate"
Display="Static"
Font-Name="verdana" Font-Size="10pt">
* valid mail server name required.
</asp:CustomValidator>

My code for validating the server name is

Sub ServerValidate (sender As Object, dnsvalue As ServerValidateEventArgs)
dim strDomain as string
dnsvalue.IsValid = False
Try
dim int as int32
int = instr(2,dnsvalue.Value,"@")
strDomain = mid(dnsvalue.value,int+1,999)
If not Dns.GetHostByName(strDomain).hostname is null Then
dnsvalue.IsValid = True
End If
Catch
End Try
RequiredEmail1.text = ""
End Sub
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top