1

I have Webform with a radio button type field named as "preferred contact method", for selecting email or phone.

When user select the email I want to set the email field as mandatory or if user select the phone I want to set phone field as mandatory.

How to handle this in Webform Drupal 7.

1
1

That is an interesting thing to have, but i don't think Webform support such a functionality. However they are some other way to achieve the same result.

Using Webform Conditional module. you can have two sets of hidden questions, and only one set of question could be visible base on user selected choice.

If user click on phone the first set of question will be display to user where the phone is a mandatory and email optional.

If user click on email the second set of question will be display to user where you can have email as mandatory and phone as optional.

You can ready more about alternative ways here .

0

You can add '#states' for the field in hook_form_alter() . Check this question How to make a form required with states?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.