Search code examples
javascriptjqueryspam-prevention

Stopping spambots with JS(jQuery) event listeners


Ok, so I've been looking around at some recommendations on how to prevent spam using JS and hidden fields, and sessions, and all sorts of other clever tricks, but none of them seem terribly good.

I have a potentially better way to do this, but just need someone to tell me if bots trigger jQuery events like "keypress", "focus", "blur", "etc".

I know I could probably eliminate bots if they had to trigger the "mouseover" event, but that doesn't help for mobile users.

I'm basically just looking for a list of JS event listeners that aren't triggered by spambots.


Solution

  • Unless spam bots are being programmed specifically for your page, usually you can just do:

    1) An input element hidden via css (move it offscreen, or behind another element, but don't actually set visibility:hidden or display:none). If it has a value, it's spam.

    2) Create a hidden input, set it's value to the current server time. When the form is submitted, see how long it took them to fill it out. Did they do it in half a second? Probably spam.