开发者

asp.net mvc regular expression phone

  [RegularExpression(@"^开发者_StackOverflow社区[a-zA-Z0-9_,:- ]*", ErrorMessage = "Phone can Contains only Only Alphanumeric Characters ")]

How can I validate accomodate () ' in the above regular expression, it is giving a parsing error.


try ^[a-zA-Z0-9_,: -]*

the hyphen needs to be at the end of the set, otherwise it's considered a range, in this case a range from : (ascii 58) to space (ascii 32). flip that part and see what happens


Try for "000-000-0000" format

[RegularExpression(@"^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$", ErrorMessage = "Entered phone format is not valid.")]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜