用于c#中电子邮件验证的Masked TextBox [英] Masked TextBox for Email validation in c#

查看:116
本文介绍了用于c#中电子邮件验证的Masked TextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正常的文本框用于输入电子邮件ID,但要求是文本框应该有@,。com本身就在其中加载页面plz通过这个回答我.....

I have a normal text box for entering Email ID, but requirement is text box should have "@", ".com" inherently in it while loading the page plz go through this answer me.....

推荐答案

您好,



您可以使用正则表达式:

http://msdn.microsoft.com/en-us/library/az24scfc.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/ms228595% 28v = vs.110%29.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx [ ^ ]

使用正则表达式电子邮件地址验证 [ ^ ]

http://stackoverflow.com/a/16168103 [ ^ ]



而不是RegEx来验证电子邮件地址,你也可以试试这个:

http://stackoverflow.com/a/16168118 [ ^ ]







只需检查给定的电子邮件地址包含@和.com不足以验证电子邮件地址:如果您只是检查@和.com,那么甚至 .com @ 有效。
Hi,

You can use a regular expression:
http://msdn.microsoft.com/en-us/library/az24scfc.aspx[^]
http://msdn.microsoft.com/en-us/library/ms228595%28v=vs.110%29.aspx[^]
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^]
Email Address Validation Using Regular Expression[^]
http://stackoverflow.com/a/16168103[^]

Instead of a RegEx to validate an email address, you can also try this:
http://stackoverflow.com/a/16168118[^]



Just checking whether the given email address contains "@" and ".com" wouldn't be enough to validate an email address: if you just would check for "@" and ".com", then even .com@ would be valid.


你真的不需要一个蒙面文本框。您应该将此代码放在要验证电子邮件的位置。



You don't really need a masked text box. You should just put this code where you want to validate the email.

if (TextBox1.Text.Contains("@")) {
    if (TextBox1.Text.Contains(".com")) {
        MessageBox.Show("Valid Email");
    }
} else {

}


这篇关于用于c#中电子邮件验证的Masked TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆