Using Pattern Trigger (Regex) in Webform Conditional Logic in Drupal 8

May 23, 2019

✅ Quick Answer: Use ^(Value1|Value2|Value3)$ in Pattern trigger to check for multiple values.

When you need to create survey style forms in Drupal 8 Webform is the clear winner. It's powerful enough to create all sorts of forms and you can even give it to your editor so they can create their own, after a little training, of course.

One part of Webform which I like is the ability to define conditional logic. For example, you can show or hide a text field based off a value from another element. You can also make an element conditionally required. It's a very useful part of Webform, and you do all of this through a UI, no custom code.

Defining simple conditional logic, check if element value has a single value, is pretty straightforward. But when you have to deal with multiple values, this is where things get tricky.

✅ Read full tutorial:

📽 Sections:

1. Create elements (01:25)
2. Add conditional logic to elements (03:14)
3. Add Pattern trigger (05:52)
4. Using Regex101 (07:51)

- Webform Module (
- Regex101 (

👥 Connect with us

#drupal #webform

Hi! I'm Karim Boudjema, the developer and site-builder of this site. I'm currently working as a freelance Drupal developer.

I was wondering how could I giving back to the Drupal community all what it gave to me during the last 10 years, that's how the idea of this site came to me ... (read more)

Hi! I’m Santiago Rico, the web designer and themer of this site.

When Karim proposed me to design and theme this site for the Drupal community, I accepted immediately because the community is the main reason why I love Drupal so much.