3

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?

Philipp
  • 67,764
  • 9
  • 118
  • 153
eric
  • 61
  • 1
  • 2
  • 2
    When you want to do spam filtering, you should do it server-sided. Most spam bots will just post the form content directly and ignore the pattern. – Philipp Dec 14 '12 at 09:34
  • On most websites I know which are plagued by spam, it's not just viagra and cialis anymore. Nowadays, the spammers advertise just about anything one can buy. – Philipp Dec 14 '12 at 09:45
  • I've already inserted a captcha, but the seem to fill in the forms manually ...(?) – eric Dec 17 '12 at 15:18
  • Many spambots use optical character recognition to break captchas. Many have algorithms tailored for commonly used captcha libraries. For more information about automatic captcha solving, see http://caca.zoy.org/wiki/PWNtcha# – Philipp Dec 17 '12 at 15:36
  • ...and when OCR isn't working, there are people in China who solve 1000 captchas for you for $1 (I am not making this up: http://boingboing.net/2012/01/09/virtual-sweatshops-versus-capt.html) – Philipp Dec 17 '12 at 15:40
  • Some sites use a slider as captcha. Does this work as a better prevention? http://demos.myjqueryplugins.com/qaptcha/ – eric Dec 18 '12 at 09:37
  • adapting my spambot for that will take about 10 minutes. – Philipp Dec 18 '12 at 09:42

2 Answers2

7

You can use this regex :

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

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

Community
  • 1
  • 1
Pilou
  • 1,398
  • 13
  • 24
0

you can use it

<input type="text" pattern="[^(^viagra$|^cialis$)]"> 
Kakitori
  • 901
  • 6
  • 16
  • 41