Uncaught SyntaxError: Invalid regular expression

2019-09-11 01:20发布

I am trying to validate an input field using the following pattern but i get this error :

<input id="testMyU" type="text" required maxlength=35 pattern="((?!((&[^\ ]*;))|([<>])).)*" >

Error :

Pattern attribute value ((?!((&[^\ ]*;))|([<>])).)* is not a valid regular expression: Uncaught SyntaxError: Invalid regular expression: /((?!((&[^\ ]*;))|([<>])).)*/: Invalid escape

I don't find my mistake ...

1条回答
三岁会撩人
2楼-- · 2019-09-11 01:23

Your problem is here:

<input id="testMyU" type="text" required maxlength=35 pattern="((?!((&[^\ ]*;))|([<>])).)*" >
                                                                        ^

Try using a double backslash.

查看更多
登录 后发表回答