1

I have a regular expression that works great when I try it:

System.Text.RegularExpressions.Regex.IsMatch("universal",@"^[A-Za-z0-9 ._’&-/s]{0,100}$")
true

System.Text.RegularExpressions.Regex.IsMatch("universal £$%$£%",@"^[A-Za-z0-9 ._’&-/s]{0,100}$")
false

But when I use it as a validation filter:

[RegularExpression(@"^[A-Za-z0-9 ._’&-/s]{0,100}$", ErrorMessage = "The parameter is not valid")]

It works in the client side, but it does not work on the server side. For example when I pass the word "universal" the ModelState contains an error regarding the field marked with that regex validator.

This attribute is the only validation rule applied to that field, what may be the problem?

Cheers.

vtortola
  • 34,709
  • 29
  • 161
  • 263
  • 2
    I'm not familiar with .NETs regex implementation, but `&-/s` looks a bit odd. Do you mean the ascii range from `&` to `/` and the the letter `s`? Or did you mean to include the special class `\s` and a literal `-`? – beerbajay Feb 21 '12 at 15:15
  • @NullOrEmpty:Hi ,i have the same problem have you found the solution? – Mohsen Jun 12 '12 at 06:48

0 Answers0