开发者

Regular Expression Validator: Client side validation

Here is the code for my regular expression on my aspx.cs page. The issue I am having is that when I use the same regular expression, ^\p{L}$ , in the regular expression validatdor on my aspx page, it doesn't work. Is there something different between regular expression validators and a regular expression pattern int the code behind?

    public static bool IsNameV开发者_开发技巧alid(string name)
    {
        string regExPattern = @"(^[\p{L}]$)";

        if ((!System.Text.RegularExpressions.Regex.IsMatch(name, regExPattern)) || name.Length > 50)
            return false;
        else
            return true;

    }


I Put te same regex "(^[\p{L}]$)" in a RegularExpressionValidator and i think it works for me. Remember that que RegularExpressionValidator in html generate a javascript validator, maybe you have some error in the JS? Try to see in firebug (or other debugger) if are any error in javascript console.

PS: Sorry for my bad english.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜