Tina's blog
开心过好每一天! Come on !
    public bool ValidationInServer(ref string errorInfo,string txt, string type)
    {
        if (type == "0" || type == "1" || type == "3")
        {//email address formart validation
           
            if (!Regex.IsMatch(txt, @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"))
            {
                errorInfo = "Please input right email address.";
                return false;
            }
        }
        if (type == "2")
        {//skype address formart validation
            if (Regex.IsMatch(txt, "^[^a-zA-Z](.*)$"))
            {
                errorInfo = "The Skype Name must be start with letter.";
                return false;
            }
            else
                if (Regex.IsMatch(txt, @"\W"))
                {
                    errorInfo = "The Skype Name contains invalid character(s).";
                    return false;
                }
                else
                    if (txt.Length < 6)
                    {
                        errorInfo = "The Skype Name must be at least 6 characters long.";
                        return false;
                    }
        }
        return true;
    }
posted on 2008-08-07 16:55  Tinachang  阅读(140)  评论(1编辑  收藏  举报