protected static Regex RCountry = new Regex(@"^[A-Za-z]{2}$");
if (!RCountry.IsMatch(Txt_DeliverContactor.Text))
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入字母!')</script>");
                    }
就是输入字母也会提示~正则式用验证控件是可以通过的
该怎么改

解决方案 »

  1.   

    protected static Regex RCountry = new Regex(@"[^A-Za-z]");
    if (RCountry.IsMatch(Txt_DeliverContactor.Text))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入字母!')</script>");
                        }
      

  2.   

    protected static Regex RCountry = new Regex(@"[^a-z]");
    if (RCountry.IsMatch(Txt_DeliverContactor.Text.ToLower()))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入字母!')</script>");
                        }
      

  3.   

    protected static Regex RCountry = new Regex(@"[^a-z]{2}$");
    if (RCountry.IsMatch(Txt_DeliverContactor.Text.ToLower()))
      {}
      

  4.   

                string str = "12";
                Regex reg = new Regex(@"(?i)^[a-z]{2}$");
                if (reg.IsMatch(str))
                    Response.Write("true");
                else
                    Response.Write("false");
      

  5.   

    看不出什么问题啊
    要不把 Text 也输出看一下是不是传输错误
    或者用 Match 方法看它到底匹配出什么了
      

  6.   


    protected static Regex RCountry = new Regex(@"^[A-Za-z]{2}$");
    if (RCountry.IsMatch(Txt_DeliverContactor.Text))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('只能输入字母!')</script>");
                        }