So when a webform is validated it sends a drupal message "X field is required", and creates a red border around the field.

For our project the red border is enough, how would I go about removing Drupal messages from triggering during validation?


You can remove it using CSS in that particular page !

Check for specific div's the page body is using and set the div.error to display:none;


Override theme_status_messages to exclude or alter the status messages.

In your case,

function your_theme_status_messages($variables) {
  $display = $variables['display'];
  $output = '';

  $status_heading = array(
    'status' => t('Status message'), 
    'error' => t('Error message'), 
    'warning' => t('Warning message'),
  foreach (drupal_get_messages($display) as $type => $messages) {
    $output .= "<div class=\"messages $type\">\n";
    if (!empty($status_heading[$type])) {
      $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
    if (count($messages) > 1) {
      $output .= " <ul>\n";
      foreach ($messages as $message) {
        if (strpos($a,'required') === false) {  // Check for any other conditions here
          $output .= '  <li>' . $message . "</li>\n";
      $output .= " </ul>\n";
    else {
      $output .= $messages[0];
    $output .= "</div>\n";
  return $output;

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.