Want to display the validation error message above the webform I have a webform created in Drupal 8 using the webform module I have to submit the data to 2 different 3rd party API. 

The scenario is I have to submit the data to the 1st API if there is no error response found then submit the data to 2nd API so now I have created a submit handler and attached the handler to the webform. Now the issue is when I got an error response message while submitting the data to 1st API and showing the  message using drupal_set_message() function everything is working fine but the form validation js not loading at this point.

The used code is like the below:

drupal_set_message(t($msg), 'error');
$form_state-&gt;setRebuild(true);


can anybody help me with this?
you can put the validation messages above the webform by -



1.put the generic element above the form

messages:
  '#type': status_messages


2.make sure the webform's status messages purge all messages using the below hook in a CUSTOM_MODULE

function CUSTOM_MODULE_webform_element_alter(array &amp;$element, \Drupal\Core\Form\FormStateInterface $form_state, array $context) {
  if (isset($element['#type']) &amp;&amp; $element['#type'] === 'status_messages') {
    $element['#pre_render'][] = 'CUSTOM_MODULE_webform_element_status_messages_pre_render';
  }
}

/**
 * Pre render callback to display status messages element.
 */
function CUSTOM_MODULE_webform_element_status_messages_pre_render($element) {
  // Replace the status messages placeholder with the rendered messages.
  // Calling drupal_get_messages(NULL, TRUE) will purge all messages, which 
  // prevent the messages block from being displayed.
  // @see \Drupal\Core\Render\Element\StatusMessages
  // @see drupal_get_messages()
  $element = [
    '#theme' =&gt; 'status_messages',
    '#message_list' =&gt; drupal_get_messages(NULL, TRUE),
    '#status_headings' =&gt; [
      'status' =&gt; t('Status message'),
      'error' =&gt; t('Error message'),
      'warning' =&gt; t('Warning message'),
    ],
  ];
  return $element;
}