-2

我正在开发一个模块,我需要从用户那里获取输入,其中一个是用户电子邮件。为了过滤掉错误的输入,我想检查对应的输入是否checkbox@符号。

有谁知道我如何使用它来检查它vb.net

4

2 回答 2

2

Aside the main question to check if a string contains the @ character and considering that you are getting your string from a user input, in your case I think is better to check if the user entered a valid mail address.

To do so there are some solutions all reported in this other SO question How do I validate email address formatting with the .NET Framework?

于 2013-05-04T09:41:21.140 回答
1

In ASP.NET you can use RegularExpressionValidator for this.

<asp:RegularExpressionValidator ID="regexEmailValid" runat="server" 
      ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
      ControlToValidate="tbEmail" 
      ErrorMessage="Invalid Email Format">
</asp:RegularExpressionValidator>
于 2013-05-04T09:41:55.763 回答