Field validation that depends on the value of another field

Antony V asked on November 14, 2017 20:17

In a custom module, I have a field that I want to make required, but only if another field on the form has a certain value. The field that I want validated appears only when the user selects an appropriate option from the other field, which is represented visually by a dropdown. That part works, but I also want to add validation. Is there any way to do that in the UI? I know, as a workaround, I can add an event hook, but I'd like to keep this logic all in one place, i.e. in the module>class>form editor.

Recent Answers


Matt Nield answered on November 15, 2017 09:00 (last edited on November 15, 2017 09:03)

If you’re using the Visibility condition, then you should be able to just mark the field as required. Kentico will not render the control of the Visibility condition is not met.

There is a good article by Jan about how to work with depending fields which might be worth reading through.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.