Sample code snippet to create custom validator in Sitecore WFFM.
public class CustomCountryValidator : FormCustomValidator{
protected override bool EvaluateIsValid()
{
var form = WebUtil.GetParent<SimpleForm>(this);
var field = (CustomDropListCountryPicker)WebUtil.FindFirstOrDefault(form, c => c is CustomDropListCountryPicker && (c as CustomDropListCountryPicker).Result.FieldName == "ddlCountry");
Control controlToValidate;
string value;
if (!String.IsNullOrEmpty(base.ControlToValidate))
{
controlToValidate = this.FindControl(base.ControlToValidate);
value = HttpContext.Current.Request[controlToValidate.UniqueID];
if(condition)
return true;
}
return false;
}
}
No comments:
Post a Comment