views:

36

answers:

1
  [RegularExpression(@"^[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.

A: 

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

y34h