验证asp.net中的电子邮件地址 [英] validate email address in asp.net
本文介绍了验证asp.net中的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
If Page.IsValid Then
Try
Dim sfbEmailValidator As New EmailValidator()
If txtFromDomain.Text.Length > 0 Then
sfbEmailValidator.SmtpHeloDomain = txtFromDomain.Text
End If
If txtSmtpPort.Text.Length > 0 Then
sfbEmailValidator.SmtpPort = Integer.Parse(txtSmtpPort.Text)
End If
If txtSmtpMail.Text.Length > 0 Then
sfbEmailValidator.SmtpFromEmail = txtSmtpMail.Text
End If
If txtDnsServer.Text.Length > 0 Then
sfbEmailValidator.DnsServers.Add(txtDnsServer.Text)
End If
sfbEmailValidator.ValidationLevel = DirectCast(Integer.Parse(ddlValidationLevel.SelectedValue), ValidationLevel)
sfbEmailValidator.Validate(txtEmail.Text)
lblResult.Text = sfbEmailValidator.SmtpTranscript.Replace("" & Chr(13) & "" & Chr(10) & "", "<br>")
Catch exc As Exception
lblResult.Text = "An exception occurred: " + exc.Message
End Try
End If
End Sub
我正在使用上面的代码来验证电子邮件地址吗?
在哪里告诉我们如何找到有效的电子邮件地址,您可以说出结果.
此邮件是否有效,请帮助我
i am using above code to validate email address ?
where tell how we can find the valid email address you can say that result .
this mail is valid or not plz help me
推荐答案
尝试在页面上使用RegularExpressionValidator
.此 ^ ]将帮助您入门.
Try using a RegularExpressionValidator
on the page. This link[^] will get you started.
u也可以通过javascript进行验证.
看到此链接
http://www.tizag.com/javascriptT/javascriptform.php [
u can do validation from javascript also.
see this link
http://www.tizag.com/javascriptT/javascriptform.php[^]
使用以下功能进行电子邮件验证.这也将验证域值.例如以下功能将仅验证以yahoo.com和gmail.com为域的电子邮件.
Use following functions for email validation. this will also validate domain values.. e.g. below functions will only validate emails having yahoo.com and gmail.com as domains.
function validate()
{
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+
这篇关于验证asp.net中的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文