I have a contact form with no sort of spam protection on my site and im receiving lots of spam, I'm going to add anti spam protection, I know i can do this with PHP, but if I stopped the form from validation if an anti spam question was wrong using jQuery, would this be sufficient? or do spam bots bypass javascript security measures?
One real simple trick is to add a input field with css style of display none. Then check if that field got filled. Since it's hidden, only bots would fill it. In php you could check if that field got filled, and if so, block it.
I would use a reCAPTCHA
. Its pretty simple to integrate it and its well documented.
Give it a try. It'll totally do its job on preventing against spam.
More here https://developers.google.com/recaptcha/docs/php
Edit:
2 things I do a lot that seem to eliminate almost all spam:
display:none
, when the page is submitted, that field should be set, but empty. If it is not empty, it is from a bot.Also, a good captcha will generally do the trick, as previously mentioned.
<form style="display:none;" id="myform" action="http://www.google.com">
...
</form>
<script>
var obj=document.getElementById('myform');
obj.action='realaction.php';
obj.style.display='block';
</script>
<noscript>You must have JavaScript enabled to contact us</noscript>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.