I have a custom regular expression attribute which implements IClientValidate so that I can use it with unobtrustive validate.
When I run it I get the following error in FireBug
SyntaxError: Invalid quantifier
match = new RegExp(params).exec(value);
It obviously does not like the regular expression that is passed to it, it is valid in C#. I can’t seem to work out what I need to do to get it to be valid in JavaScript.
The regex is
^(?i)([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]?\s?[0-9][ABD-HJLN-UW-Z]{2})$
The JavaScript regex flavor is extremely limited compared to .NET (C#). One of the many features it doesn’t support is inline modifiers of the form
(?i)regexor(?i:regex). However, because you’re using thenew RegExp(params)constructor, you should be able to pass the modifier as the second parameter: