📜 ⬆️ ⬇️

Spam protection for small sites

Recently, there have been several posts on Harb about protecting sites from spam bots. I decided to join and describe the method that I use myself. I have been using it for a long time and most likely it will be known to many, but I think there will be those who will be interested.

The main task.
Make it so that everyone passing by the bot does not spam through the form on the site. Make filling the form for the user as easy as possible (get rid of captcha).

The bottom line.
We display alternately fields. At the same time, we make all the odd ones (1, 3, 5 ...) hidden. In case hidden fields are filled, we consider that the sent data is spam. Additionally, I call the fields that should not be filled in as name, email ...

Implementation.
')
< form >
< div > Name: < br >< input type ="text" name ="asdasd" ></ div >
< div > Sfdd: < br >< input type ="text" name ="name" ></ div >
< div > Email: < br >< input type ="text" name ="xcbxcb" ></ div >
< div > asfaf: < br >< input type ="text" name ="email" ></ div >
< input type ="submit" value ="Send" >
</ form >

< script >
$( 'div' ).filter( ':odd' ).hide();
</ script >


* This source code was highlighted with Source Code Highlighter .
< form >
< div > Name: < br >< input type ="text" name ="asdasd" ></ div >
< div > Sfdd: < br >< input type ="text" name ="name" ></ div >
< div > Email: < br >< input type ="text" name ="xcbxcb" ></ div >
< div > asfaf: < br >< input type ="text" name ="email" ></ div >
< input type ="submit" value ="Send" >
</ form >

< script >
$( 'div' ).filter( ':odd' ).hide();
</ script >


* This source code was highlighted with Source Code Highlighter .
< form >
< div > Name: < br >< input type ="text" name ="asdasd" ></ div >
< div > Sfdd: < br >< input type ="text" name ="name" ></ div >
< div > Email: < br >< input type ="text" name ="xcbxcb" ></ div >
< div > asfaf: < br >< input type ="text" name ="email" ></ div >
< input type ="submit" value ="Send" >
</ form >

< script >
$( 'div' ).filter( ':odd' ).hide();
</ script >


* This source code was highlighted with Source Code Highlighter .



Dignity.
1. Solves the problem
2. Easy implementation

Disadvantages.
1. With CSS disabled, the user will fill in the fields
2. In my implementation with JS disabled, the user will fill in the fields

Source: https://habr.com/ru/post/66915/


All Articles