How does RegularExpressionAttribute (System.ComponentModel.DataAnnotations) handle the translation from .NET Regular Expression pattern flavor to the javascript flavor in order to do the validations client-side?
I’m guessing that there is no translation at all, and the regular expression pattern indicated in the attribute must be compatible enough with both engines.
Thanks
Your guess is correct, the regular expression is not being translated in any way, just being directly passed to the client side. This can be easly verified by checking the source code of
RegularExpressionAttributeAdapterandModelClientValidationRegexRuleclasses.You can check the following question for more informations about differences between C# and JavaScript Regular Expressions engines: Differences between C# and JavaScript Regular Expressions