1

I was hoping to get some direction on how to make a textfield in my webfrom mandatory but only if a particular select option was not checked.

So the textfield is mandatory by default but if the select option is checked, the text filed is no longer mandatory. I have tried to do this via jquery but have then read that validation is server side so I'm not sure what best practice is for this.

Does this type of behavior need custom validation via hook_form_alter() - or is there another way to achieve this? I am running Drupal 7.

Thank you in advanced.

1

I found a module called Webform Validation that lets you achieve this without any custom code.

To accomplish the above, add the 'Require at least one of two fields' validator under 'form validation' and then select both components that you want to validate against.

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.