WFFM-表单上的自定义验证类未命中(Sitecore 8.2)

时间:2018-08-16 14:58:01

标签: forms validation webforms sitecore web-forms-for-marketers

我有一个表单,我正在尝试向电子邮件字段添加自定义验证,以阻止禁止的域。我在Sitecore中创建了验证项,并将其添加到我的字段中:

enter image description here

enter image description here

然后我在项目中创建了相应的类:

namespace Example.Library.WebForms.Validators
{
public class EmailValidation : FormCustomValidator
{

    public EmailValidation()
    {
        this.ServerValidate += this.ValidateEmailAddress;
    }
    private void ValidateEmailAddress(object source, ServerValidateEventArgs args)
    {
        var blacklistFolder = Sitecore.Context.Database.GetItem(exampleConstants.exampleBlacklistFolder);
        var domains = blacklistFolder.Axes.GetDescendants().Select(x => x.GlassCast<IRestricted_Domain>());\

        var email = args.Value;

        foreach (var dom in domains)
        {
            var domain = dom.Domain;
            if (email.ToLower().EndsWith(domain.ToLower()))
            {
                args.IsValid = false;
            }
        }
    }
}
}

但是它似乎没有做任何事情,并且当我调试并附加到ValidateEmailAddress方法时,它永远不会命中它。我想念什么?

编辑:我将程序集从Example.Library更改为Example.Library.dll,但仍然没有成功。

0 个答案:

没有答案