How to make a form required with states? I have a drop down list that displays various fields based on what is chosen and I know that I can toogle the visibility with states but when I try to use required the * span is display but it isn't actually required. What I mean is that even though it's "required" I can hit submit and not get an error message from drupal. Am I doing something wrong or is this currently broken in Drupal 7.8?

        $form['host_info'] = array(
        '#type' =&gt; 'select',
        '#title' =&gt; t("Host Connection"),
        '#options' =&gt; array(
          'SSH2' =&gt; t('SSH2'),
          'Web Service' =&gt; t('Web Service'),
        ),
        '#default_value' =&gt; t(variable_get('host_info', 'SSH2')),
        '#description' =&gt; t("Specify the connection information to the host"),
        '#required' =&gt; TRUE,
    );

    $form['ssh_host'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t("Host Address"),
        '#description' =&gt; t("Host address of the SSH2 server"),
        '#default_value' =&gt; t(variable_get('ssh_host')),
        '#states' =&gt; array(
            'visible' =&gt; array(
                ':input[name=host_info]' =&gt; array('value' =&gt; t('SSH2')),
            ),
            'required' =&gt; array(
                ':input[name=host_info]' =&gt; array('value' =&gt; t('SSH2')),
            ),
        ),
    );

    $form['ssh_port'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t("Port"),
        '#description' =&gt; t("Port number of the SSH2 server"),
        '#default_value' =&gt; t(variable_get('ssh_port')),
        '#states' =&gt; array(
            'visible' =&gt; array(
                ':input[name=host_info]' =&gt; array('value' =&gt; t('SSH2')),
            ),
            'required' =&gt; array(
                ':input[name=host_info]' =&gt; array('value' =&gt; t('Web Service')),
            ),
        ),
    );
You will need to validate this yourself in a custom validate function.

Everything configured by #states happens 100% in the browser, everything that it does is not visible for Drupal when the form is submitted (for example, all invisible form field are submitted and validated in the same way if there were no #states).