Skip to content

Magento2 make one field required

I have a custom form created in Magento2 which has 4 different types of <input type=" text"> fields, I want to make sure the user enters at least one of those input field(s) and that can be anyone but least one of the fields should be required. And if a user does not input anything in all these 4 fields, s/he should receive an error that one of these inputs must be entered, etc. To simplify my question, Are there any Magento validation classes that I can use to validate in such a scenario? I can see these magento2 validation rules validate-one-required-by-name validate-one-required still exist but these are mainly being used by orand does not work for`