Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Dan Matthews
Sep 13, 2013
  4780
(0 votes)

Avoiding spam with XForms

Simple instructions: If you are using a WebForms based EPiServer 7 site, Install this AddOn then add a text box to your form of type ‘Maths Problem’. Save your form and you should be up and running!

More detail:-

We all have a love-hate relationship with XForms in EPiServer. They are quick, easy, standard… but not very flexible. One such issue with flexibility is the need to put some kind of spam-catching filter onto forms. Traditionally, we’d use a CAPTCHA or reCAPTCHA, but using this with XForms has three drawbacks:

  • You need to put in on the page or block that embeds the form, so it’s not very flexible as to when you show it (although you could add a ‘show spam catching’ flag if you wanted – it’s a bit of work)
  • Because it’s not part of the XForm, you need to put it above your form or at the bottom below your submit, which is ugly
  • It’s hard to do client-side validation with a reCAPTCHA, so you have to do it server-side which is a nuisance

As using these is quite a heavy thing to implement, I decided to find a simpler solution. One alternative that is cropping up in a few places is the ‘maths problem’ approach. It’s a very simple sum (one that even my six year old son could do easily) but one that the spammers haven’t fully exploited yet with an automatic solver. I’m sure they will, but right now if you avoid the big company implementations which are targeted for cracking, then you can avoid the worst of the bot-based spam form submissions. Because it’s so simple, it’s easy to write an AddOn that intercepts the XForm calls and sets up a sum to solve.

This implementation adds a new XForm data type of ‘Maths Problem’ which you can put on your form:

image

When the form is rendered, some code will intercept this field and add a sum to it, along with validators to ensure the sum is filled in correctly:

image

image

With this solution, you can decide where your maths problem goes and how it is styled.

Known issues:-

  • Will probably only work with WebForms, haven’t tried with MVC yet
  • Currently the validation error is fixed and only in English

Disclaimer:-

This AddOn is provided As-Is. I haven’t tested it fully and it was a quick throw-together for another project I’m working on. Use it at your own risk!

Sep 13, 2013

Comments

Eva Bengtsson
Eva Bengtsson Jan 24, 2014 01:56 PM

this is exactly what I was looking for, however, I am on EPiServer 6 - What do you suggest to do?

Feb 11, 2014 08:25 AM

Hey Eva - I only just picked up your question, sorry! I think this should work on EPiServer 6 as well but I'd have to recompile a version for you to copy in directly. Let me know if you still need it ;)

Radha Jujjavarapu
Radha Jujjavarapu Mar 27, 2014 08:19 PM

I am on Episerver 7.1 and I have installed this add on but I don't see "Maths Problem" in the drop down.

Apr 24, 2014 05:15 PM

Did you restart your site, Radhu?

camilo
camilo Feb 7, 2018 10:15 AM

Hi Dan,

The link to the code is not left.
Do you have it left would be grateful for it

/Camilo

Please login to comment.
Latest blogs
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog