I have an MVC 4 model and am creating html from it in the view using @Html.TextBoxFor. In the model for one of the fields I have a RegularExpression attribute defined as follows:
[Required(ErrorMessageResourceType=typeof(ResourceFile), ErrorMessageResourceName="ResourceName1"
[RegularExpression(@"\w{3,5}", ErrorMessageResourceType=typeof(ResourceFile), ErrorMessageResourceName="ResourceName2")]
public string TestProperty { get; set; }
Note the expression is more complex than this but what I have here is suitable for testing. I have set up unobtrusive client side validation as described here: http://bradwilson.typepad.com/blog/2010/10/mvc3-unobtrusive-validation.html
The problem I have is that I need to accept Russian characters. .Net's regular expressions have a different meaning for \w to javascript's regular expressions and as such server side validation works as I expect and client side does not.
Is it possible to turn off client side validation for the RegularExpression attribute without turning it off for the Required attribute?
Failing that is it possible to just turn off client side validation for this single property without switching off for all the other properties on that model object?