You are here

public static function TextBase::validateInputMask in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/WebformElement/TextBase.php \Drupal\webform\Plugin\WebformElement\TextBase::validateInputMask()

Form API callback. Validate input mask and display required error message.

Makes sure a required element's value doesn't include the default input mask as the submitted value.

Applies only to the currency input mask.

File

src/Plugin/WebformElement/TextBase.php, line 259

Class

TextBase
Provides a base 'text' (field) class.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public static function validateInputMask(&$element, FormStateInterface $form_state, &$complete_form) {

  // Set required error when input mask is submitted.
  if (!empty($element['#required']) && static::isDefaultInputMask($element, $element['#value'])) {
    WebformElementHelper::setRequiredError($element, $form_state);
  }
}