Creating a contact form on your business website can be a great thing. It can help you generate leads and answer questions from current clients, but it can also generate quite a bit of spam. Preventing spam may even seem like a full time job; as a small business owner you don’t have time for it. There are lots of ways to help prevent spam (including the honey pot technique, which we previously covered). They all seem to cut down on the spam, but do any of them stop the spam for good? As a web developer, the best approach is to use multiple techniques.
WARNING: Technical details ahead! You might want to pass this blog post on to your web developer.
tag will not have the ‘js’ class and the form action will be blank. The form will not submit, which will stop the spam.
In the example below, we will be using jQuery. Load the jQuery library in the
tag above all other script references. You can pull it from the Google CDN or save it locally.
Next, download Modernizr and add the script in the
tag below the jQuery reference.
tag of ‘js’ that we can exploit. You can see in the image that it’s the first class it appends. You won’t be able to see these appended classes in the source code of the page, so you’ll need to use F12 Developer Tools (for Internet Explorer), Firebug (for Firefox) or Developer Tools (for Chrome).
Next up is another script we add to the
tag after the Modernizr script. Its job is to check if the
tag has a class of ‘js’ and assign it to a variable. If this variable exists or is true, then two things happen. First, we assign the form action URL to a variable. Second, we attribute the variable to the form action.
Putting it all together.