Skip to content Skip to sidebar Skip to footer

Regex On Chrome Pattern Input Validation

I have an RFC 5322 compliant email regex pattern to validate my input. This works in all browsers, but Chrome show me the following error on console: Pattern attribute value ^[-a-z

Solution 1:

Since Chrome pattern attribute automatically adds u modifier, stricter rules for regex syntax are applied. Basically, you cannot escape arbitrary symbols. If the symbol is not a special regex metacharacter, you cannot escape it, or you will get this error.

So, in your case, the single apostrophe must not be escaped. Remove the escaping backslash before it, and the regex will work in every browser again.

Post a Comment for "Regex On Chrome Pattern Input Validation"