November Happy Hour will be moved to Thursday December 5th.

Dan Matthews
Sep 13, 2013
  4951
(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
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog