Sitecore CustomValidator does not fire on WFFM custom field

风流意气都作罢 提交于 2019-12-06 00:19:32

You will want to move your validation code to a new class that implements FormCustomValidator.

public class MySingleLineTextValidator : FormCustomValidator
{ 
    protected override bool EvaluateIsValid()
    {
        if (!String.IsNullOrEmpty(base.ControlToValidate))
        {
            Control controlToValidate = this.FindControl(base.ControlToValidate);
            //Code to validate
        }

        return false;
    }}

Then you will need add a BaseValidator Item in the WFFM Validation Folder, usually this path; /sitecore/system/Modules/Web Forms for Marketers/Settings/Validation. Add the assembly and class to the item.

Now against your custom Field, add the your new BaseValidator item in the Validation field and that's it.

See this post of a wffm custom form validator for a full example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!