Conditional required doesn't work properly with novalidate attribute

Steps to reproduce:

1. Create a webform with a radios type element with "Yes/No" options
2. Create a textarea element which will be required if "Yes" is selected
3. Disable client-side validation at Form Behaviors
4. Visit the form select "Yes" and try to submit

This is source (YAML), also an entire configuration is provided

yes_or_no:
  '#type': radios
  '#title': 'Yes or No'
  '#options': yes_no
conditional_field:
  '#type': textarea
  '#title': 'Conditional field'
  '#states':
    required:
      ':input[name="yes_or_no"]':
        value: 'Yes'
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

javivf created an issue. See original summary.

jrockowitz’s picture

Status: Active » Closed (works as designed)

Conditional required elements only work using clientside validation because Webform 8.x-5.x is using Drupal's #states API.

@see #2807571: [meta] Webform 4.x features currently missing from the YAML Form module