Sitecore 9 Forms - Some of many validations

I want to check two single line input fields, whether one of them is filled. But one of them must be filled. Can i set up a validation in the CMS?


For my understanding in custom validitions, its not possible. Because the only information the custom validations has, is the validation type itfself and the value of the input that is currently checked.

  • You need to create,

    1. Create Custom validation for forms "RequiredFieldValidationsforMultiple"
    2. Override Validate method of ""RequiredFieldValidationsforMultiple"" and check for the value in both fields,
    var data = this.FormDataProvider.GetEntries(formId, null, null);
    foreach (var item in data)
    var FirstFeildValue = item.Fields.Where(x => x.FieldName == "FieldName1").FirstOrDefault();
    var SecondFeildValue = item.Fields.Where(x => x.FieldName == "FieldName2").FirstOrDefault();
    // Check FirstFieldValue & SecondFieldValue and return the results

    3. Assign custom validations i.e ""RequiredFieldValidationsforMultiple"" for both fields in content editor

    Hope this helps!
  • I think the conditional logic for your forms may also help you :
    It is a Sitecore 9.1 + feature. and it is more about enable or disable fields instead of a validation.