我正在开发一个模块,我需要从用户那里获取输入,其中一个是用户电子邮件。为了过滤掉错误的输入,我想检查对应的输入是否checkbox
有@
符号。
有谁知道我如何使用它来检查它vb.net
?
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?
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>