Jazcash
Jazcash

Reputation: 3314

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.

Upvotes: 1

Views: 1065

Answers (2)

JanH
JanH

Reputation: 519

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

Upvotes: 1

Roman Hutnyk
Roman Hutnyk

Reputation: 1549

First of all use Forms -> Fields - it gives you much more options. Form builder is for content editors and covers simple scenarios.

Under Fields tab navigate fields that other fields depend on and check Has depending field. Now switch to depending field, check Depends on another field and enter some macro into visibility or enable condition.

Also it should be enough to enter Email vs. Email.value

Upvotes: 0

Related Questions