Dan Matthews
Sep 13, 2013
  4858
(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
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024