Search code examples
kentico

How to make a field depend on the value of another field in Kentico form builder


I'm creating a contact form which should allow the user to enter either phone or email or both. My conditions would be something like:

Email.value != "" || Phone.value != ""

I just have no idea how to write this as a K# macro rule in the Forms -> Form Builder -> Field Validation -> General Condition editor. Is it even possible to get the value of other fields? All the predefined rules are completely unrelated to the current form data.


Solution

  • Your condition is correct. The problem is that the validation happens only for non-empty fields. If you have any required field in your form, put the condition there and then style the validation, or create dummy required field for same purpose. Similar as here:

    http://devnet.kentico.com/articles/tweaking-kentico-(1)-hidden-required-fields