阅读812 返回首页    go 阿里云 go 技术社区[云栖]


验证特殊字符

 

        #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

 

原帖地址:https://blog.sina.com.cn/s/blog_7f218dc7010117kv.html

最后更新:2017-04-02 06:52:25

  上一篇:go 360准备起诉山东电视台 称浏览器相关报道不实
  下一篇:go J2EE空链接a标签的处理方法