HTML5 pattern exclude words

♀尐吖头ヾ 提交于 2019-12-10 23:49:17

问题


I want to exclude some unwanted words in an input field of textarea using the pattern function in HTML5.

so I want exclude word inside a text like 'viagra' and 'cialis'

How can I code this?


回答1:


You can use this regex :

^((?!viagra)(?!cialis).)*$

As explained in the post : Regular expression to match a line that doesn't contain a word?




回答2:


you can use it

<input type="text" pattern="[^(^viagra$|^cialis$)]"> 


来源:https://stackoverflow.com/questions/13875922/html5-pattern-exclude-words

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!