spamDon’t you just hate it it when your website has a contact form and all you receive is email after email of advertising, porn web links and Viagra? Well I do anyway. While there are ways for your email client to filter the spam, there are ways to help dramatically reduce the spam sent through your contact form.

The problem

The problem is that automated scripts / users fill out forms advertising information which is considered garbage. While to us we do not take any notice but for them a link helps improve their site in search results or make money and even some cases spread viruses. It is a major problem that is not going away anytime soon.

The solution

The standard solution
Server side validation using a regular expression or validation routine checks for valid emails and to apply strict rules in the inquiry area. For example not allowing emails, web addresses. This depends on what information you are gathering from the form. This can be programmed in such languages such as ASP and PHP. This is basic practice but in conjunction with other methods this can be improved.

The client side
Probably the poorest form of validation is client side. This is mainly for the user using the form. Based on JavaScript this can easy be turned off by the user and automated scripts can easy bypass this method. This should be used in conjunction with server side validation and never use this on its own.

Advanced spam checks

Now we know 2 forms of methods in conjunction can help reduce spam you can also apply these advanced methods to produce a stable contact form which can reduce spam to almost zero.

Domain validation
Within your code you should compare against the domain it is sending from. When sending information through a form you will go through this through a web address i.e. www.skylight-studios.co.uk. This helps prevent scripts from accessing a form through through another portal and only email is sent through your domain is accepted.

Captcha
This is a popular way of reducing spam. While not full proof and for accessibility can prove problematic still a great way where a user can identify what is written on the screen and follow human instructions where scripts can not pass. While this was the most efficient way of reducing spam, use this with caution as it can cause problems with the user.

Hidden field
This is a very clever way to reduce spam. Within the fields that are sent through the system an included hidden field where anything gets inputted the email is instantly rejected. This is not hidden as a property within the form but hidden through CSS from the user where scripts are not able to process. Scripts run through forms filling out information to send but even the most advanced scripts will not be able to tell which fields should not be filled thus fooling the script.

Overall

Getting a right mixture of email validation and checks can help reduce spam but overload the system can cause ordinary users to move elsewhere. Simplicity, subtle and gracefully is the key to how the validation process should work. Clients do not like spam as I have come across it many times when developing websites.