Sitecore WFFM Required Field Validator Not Working On Upgrade

Recently, I updated WFFM from Sitecore 7.2 to 7.5. Asides from a few issues with the upgrade the only big error that came out of testing was the required field validator stopped working as expected on all the drop list on the site. After a bit of poking around the internet, I couldn't see a lot of information about how to troubleshoot issues with WFFM, so in today's guide, I'm going to hopefully cover some of it.

Where Are The WFFM Settings?

The first thing you will need to know when troubleshooting WFFM is where to find its setting in Sitecore. In the editor you need to go to 'Sitecore' -> 'System' - > 'Modules' -> 'Web Forms For Marketers' -> 'Settings'. WFFM_Troubleshooting_1 In here you can find things like validation rules, the available field types to use within a form, the save actions on how WFFM will behave when a form is submitted and a few other treats. As I had a validation issue between versions from upgrading, the first thing I wanted to do was check that all the upgraded validation items matched the live working version. WFFM_Troubleshooting After comparing the two trees, everything looked to be in order. At this point, I went to Sitecore support who recommended I created a custom validator. In the end, this approach would have been complete overkill for my problem, but I'm adding it here in case someone else might find it useful. After speaking to Sitecore support, one way you could resolve this issue (not recommended) is to override how the default required field validator work for the form. The WFFM related to validation can be found in the 'System' -> 'System Validation' folder, or, the 'Validation' folder. WFFM_Troubleshooting_2 To override how WFFM deals with all required field values, you need to look at the 'NotEmpty' item in the master database, found here:
/sitecore/system/Modules/Web Forms for Marketers/Settings/System/System Validation/NotEmpty
The class that Sitecore will call when it tries to validate is set in the class field, as seen above. If you want to write your own custom validator you would write some code that implements 'RequiredFieldValidator'. Using Reflector to look at the default 'Sitecore.Form.Validators.RequiredWithMarkerValidator' we see this code:
using System;
using System.Web.UI.WebControls;

namespace Sitecore.Form.Validators
  public class RequiredWithMarkerValidator : RequiredFieldValidator, ICloneable
    public string Marker
        return this.Attributes["marker"];
        this.Attributes["marker"] = value;

    public virtual object Clone()
      RequiredWithMarkerValidator withMarkerValidator = new RequiredWithMarkerValidator();
      this.CopyBaseAttributes((WebControl) withMarkerValidator);
      withMarkerValidator.ErrorMessage = this.ErrorMessage;
      withMarkerValidator.Text = this.Text;
      withMarkerValidator.Marker = this.Marker;
      withMarkerValidator.ToolTip = this.ToolTip;
      withMarkerValidator.ValidationGroup = this.ValidationGroup;
      withMarkerValidator.Display = this.Display;
      withMarkerValidator.ID = this.ID;
      withMarkerValidator.ControlToValidate = this.ControlToValidate;
      withMarkerValidator.CssClass = this.CssClass;
      withMarkerValidator.InitialValue = this.InitialValue;
      withMarkerValidator.EnableClientScript = this.EnableClientScript;
      withMarkerValidator.Enabled = this.Enabled;
      withMarkerValidator.ForeColor = this.ForeColor;
      withMarkerValidator.SetFocusOnError = this.SetFocusOnError;
      return (object) withMarkerValidator;

This code isn't that helpful but if you look in the base class, RequiredFieldValidator you can find the 'EvaluateIsValid()' method:

        protected override bool EvaluateIsValid() {

            // Get the control value, return true if it is not found
            string controlValue = GetControlValidationValue(ControlToValidate);
            if (controlValue == null) {
                Debug.Fail("Should have been caught by PropertiesValid check");
                return true;

            // See if the control has changed
If you wanted to go down this route, you can create a custom validator based on the standard one and extend it with logic to meet your needs, however, if you are simply struggling with a drop list and the required field error it is very likely there is a much more simpler resolution.

How To Solve Drop List Required Field Validation Error

Instead of writing a custom validator as recommended by support, which seemed wrong to me, I compared the HTML between the working live version of the form which used WFFM 2.4 to the upgraded version 2.5. The HTML can be seen below: Working
<div class="selecter-options">
    <span class="selecter-item selected" data-value=" ">Title</span>
   <span class="selecter-item" data-value="Mr">Mr</span>
   <span class="selecter-item" data-value="Mrs">Mrs</span>
<div class="selecter-options" style="display: block;">
   <span class="selecter-item selected" data-value="Please select">Please select</span>
   <span class="selecter-item" data-value="Mr">Mr</span>
   <span class="selecter-item" data-value="Mrs">Mrs</span>
In case you didn't spot it, the main difference between the two is that the data-value item is empty on the existing working one, but it is populated on the upgraded one. WFFM_Troubleshooting_3 If I looked at my 'Please Select' key value, it's empty. When upgrading WFFM previously an empty value would output an empty value. From 3.5 upwards if you have a completely empty value Sitecore will use the 'Text' as the 'Value' in the dropdown on the form. This now makes sense to me why the required field validator on the drop list stopped working. The working version doesn't output a value in the HTML and on submission, the required field validation is triggered because it's empty. The upgraded version is now adding in the name into the value (even though it doesn't exist in Sitecore) on submission this passes the required validation rule. To fix the issue I added a few blank spaces into the value field (rather than it being completely empty). This fixed the form and made my validation work: WFFM_Troubleshooting_4

Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge

Back to top