开发者

asp.net mvc regular expression phone

开发者 https://www.devze.com 2023-01-18 21:03 出处:网络
[RegularExpression(@\"^开发者_StackOverflow社区[a-zA-Z0-9_,:- ]*\", ErrorMessage = \"Phone can Contains only Only Alphanumeric Characters \")]
  [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

精彩评论

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

关注公众号