0

Is it possible to use jQuery to disable the submit button of a form element as a way of preventing spam bots?

For example asking the user to add 2+2?

If the form field had the value of 4, then enable the Submit button.

Would it help at all or are the spam bots easily able to get bye something like this?

Stefan
  • 754
  • 4
  • 9
  • 20
  • Do you have any control at all of the external site? If not, there isn't a whole lot you can do since the spam bots typically submit directly to the server. – Kevin B Feb 06 '12 at 20:50

2 Answers2

3

Chances are the spambots won't execute the JavaScript that's disabling the submit button in the first place. If you have no control over the form's destination, there's not much you can do to prevent this sort of spam.

ceejayoz
  • 165,698
  • 38
  • 268
  • 341
  • Sure -- _"If you have no control over the form's destination, there's not much you can do to prevent this sort of spam."_ __To me, this is false.__ See my suggestion. – calebds Feb 06 '12 at 21:57
  • 1
    A spammer would only need to solve the captcha once with your solution - once they have the form, they can post to it as much as they like. Like I said, "not much". – ceejayoz Feb 06 '12 at 22:03
  • That's a good point, if spammers solving CAPTCHAs is a concern. – calebds Feb 07 '12 at 17:26
1

With spam, the problem is not that the submit button is visible or clickable. This make no difference to spambots. What matters is that the form inputs and action are exposed, making it possible to programmatically fire a valid request to the server. There's really no guaranteed way of preventing spam exclusively with client-side technologies.

Here's a suggestion: Set up ReCaptcha with your own server that will send back the form HTML (e.g. with AJAX). The form knowledge is safe on your server until the requester is known to be human (via CAPTCHA).

More Ideas

Community
  • 1
  • 1
calebds
  • 23,502
  • 7
  • 39
  • 73
  • Thank you for the suggestion, I was thinking about this myself but unfortunately I am not very nifty with PHP and/or AJAX etc... I am mostly just front end and even the majority of my jQuery is really for animation purposes. I was hoping I could bumble my way through a simple solution but clearly I am out of my depth (blasted bots!). – Stefan Feb 06 '12 at 21:10
  • No problem. Just to be clear, above suggestion is as secure as if you had access to the form server. – calebds Feb 06 '12 at 21:55