In an ASP.NET MVC 3 project I have a requirement to validate a name field in a view to allow a specific set accented characters. So in my view model I have an regular expression attribute defined on the appropriate property like this:
[RegularExpression("^[a-zA-Zá]{2,50}$")]
Please note this is not the exact code, it is simplified to make my problem easier to understand.
This regular expression works fine server side, but doesn't work client side. If you view the HTML of the input field is contains this attribute:
data-val-regex-pattern="^[a-zA-Zá]{2,50}$"
As you can see the accented character has been converted into a HTML entity which breaks the regular expression. Can anyone tell me why this is happening and how to fix it?
UPDATE
Apologies I am a complete moron. I had completely forgotten that we upgraded to MVC 4 beta a couple of days ago. Subsequently I've created a two small test projects, one in MVC 3 and one in MVC 4. The problem only exists in MVC 4.