#region 验证是否特殊字符
/// <summary>
/// 验证是否特殊字符
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static bool IsSpecial(string text)
{
Regex regExp = new Regex
("[~!@#$%^&*()=+[\\]{}\"'.;:/?><`|!·¥…—()\\-、;:。?,“”‘’》《]");
if (regExp.IsMatch(text))
{
return true;
}
else
{
return false;
}
}
#endregion
#region 屏蔽特殊字符
private void txt_Product_KeyPress(object sender, KeyPressEventArgs e)
{
if (Lepus.RJ.InfoBase.Jscript.IsSpecial(e.KeyChar.ToString()))
{
e.Handled = true;
}
else
{
e.Handled = false;
}
}
#endregion
原帖地址:http://blog.sina.com.cn/s/blog_7f218dc7010117kv.html