【发布时间】:2016-02-27 04:12:15
【问题描述】:
我想在创建 companyId 时进行控制,以不允许创建带有特殊字符(如 (&)、(/)、()、(ñ)、(') 的 id):
If txtIdCompany.Text.Contains("&") Then
// alert error message
End If
但我不能这样做:
If txtIdCompany.Text.Contains("&", "/", "\") Then
// alert error message
End If
如何在同一行中检查多个字符串?
【问题讨论】:
-
我提出这个答案是因为我还没有在其他页面中找到解决方案。谢谢
-
其他 Unicode 符号或外来字符呢?您可能希望使用允许字符的白名单,而不是不允许字符的黑名单。
-
我建议使用正则表达式 - 类似于此处使用的 stackoverflow.com/questions/2788727/…
标签: asp.net vb.net string contains