Form element validation handler for entity_autocomplete elements.
968746
public static function validateEntityAutocomplete(array &$element, FormStateInterface $form_state, array &$complete_form) {
    $duplicated_values = $value = [];

    // Load the current Event enrollments so we can check duplicates.
    $storage = \Drupal::entityTypeManager()->getStorage('event_enrollment');

    if (empty($nid)) {
      $node = \Drupal::routeMatch()->getParameter('node');
      if ($node instanceof NodeInterface) {
        // You can get nid and anything else you need from the node object.
        $nid = $node->id();
      }
      elseif (!is_object($node)) {
        $nid = $node;
      }
    }

    // Grab all the input values so we can get the ID's out of them.
    $input_values = Tags::explode($element['#value']);
    foreach ($input_values as $input) {
      $match = static::extractEntityIdFromAutocompleteInput($input);
      if ($match === NULL) {
        $options = $element['#selection_settings'] + [
          'target_type' => $element['#target_type'],
          'handler' => $element['#selection_handler'],
        ];

        /* @var /Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */
        $handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options);
        $autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface;
        // Try to get a match from the input string when the user didn't use
        // the autocomplete but filled in a value manually.
        // Got this from the parent::validateEntityAutocomplete.
        $match = static::matchEntityByTitle($handler, $input, $element, $form_state, !$autocreate);
      }

      if ($match !== NULL) {
        $value[$match] = [
          'target_id' => $match,
        ];

        $enrollments = $storage->loadByProperties(['field_event' => $nid, 'field_account' => $match]);

        // User is already a member, add it to an array for the Form element
        // to render an error after all checks are gone.
        if (!empty($enrollments)) {
          $duplicated_values[] = $input;
        }

        // Validate input for every single user. This way we make sure that
        // The element validates one, or more users added in the autocomplete.
        // This is because we don't allow adding multiple users at once,
        // so we need to validate single users, if they all pass we can add
        // them all in the _social_group_action_form_submit.
        parent::validateEntityAutocomplete($element, $form_state, $complete_form);
      }
    }

    // If we have duplicates, provide an error message.
    if (!empty($duplicated_values)) {
      $usernames = implode(', ', $duplicated_values);

      $message = \Drupal::translation()->formatPlural(count($duplicated_values),
        "@usernames is already enrolled, you can't add them again",
        "@usernames are already enrolled, you can't add them again",
        ['@usernames' => $usernames]
      );

      // We have to kick in a form set error here, or else the
      // GroupContentCardinalityValidator will kick in and show a faulty
      // error message. Alter this later when Group supports multiple members.
      $form_state->setError($element, $message);
      return;
    }

    if ($value) {
      $form_state->setValue('entity_id_new', $value);
      $form_state->setValue('node_id', $nid);
    }
  }
1019874
def submit_by_selector(self, selector):
    """"""
    elem = find_element_by_jquery(world.browser, selector)
    elem.submit()
1153634
def validateTagAttributes(self, attribs, element):
		""""""
		out = {}
		if element not in _whitelist:
			return out
		whitelist = _whitelist[element]
		for attribute in attribs:
			value = attribs[attribute]
			if attribute not in whitelist:
				continue
			# Strip javascript "expression" from stylesheets.
			# http://msdn.microsoft.com/workshop/author/dhtml/overview/recalc.asp
			if attribute == u'style':
				value = self.checkCss(value)
				if value == False:
					continue
			elif attribute == u'id':
				value = self.escapeId(value)
			# If this attribute was previously set, override it.
			# Output should only have one attribute of each name.
			out[attribute] = value
		return out
622544
function() {
      // Create the div wrapper for this group
  	   this.divEl = inputEx.cn('div', {className: this.options.className});
	   if(this.options.id) {
   	   this.divEl.id = this.options.id;
   	}
   	  	   
  	   // Create the FORM element
      this.form = inputEx.cn('form', {method: this.options.method || 'POST', action: this.options.action || '', className: this.options.className || 'inputEx-Form'});
      this.divEl.appendChild(this.form);

		// set the enctype
		if(this.options.enctype) {
			this.form.setAttribute('enctype',this.options.enctype);
		}

	   // Set the autocomplete attribute to off to disable browser autocompletion
		this.form.setAttribute('autocomplete', this.options.autocomplete ? 'on' : 'off');
   	
      // Set the name of the form
      if(this.options.formName) { this.form.name = this.options.formName; }
  	   
  	   this.renderFields(this.form);

      this.renderButtons();
      
      if(this.options.disabled) {
  	      this.disable();
  	   }	  
   }
576659
public void displayValidation(String entityId, CmsValidationResult validationResult) {

        if (m_formTabPanel != null) {
            CmsAttributeHandler.clearErrorStyles(m_formTabPanel);
        }
        m_rootHandler.visit(CmsValidationHandler::clearValidation);
        if (validationResult.hasWarnings(entityId)) {
            for (Entry<String[], String> warning : validationResult.getWarnings(entityId).entrySet()) {
                String[] pathElements = warning.getKey();
                // check if there are no errors for this attribute
                if (!validationResult.hasErrors(entityId)
                    || !validationResult.getErrors(entityId).containsKey(pathElements)) {
                    CmsAttributeHandler handler = m_rootHandler.getHandlerByPath(pathElements);
                    if (handler != null) {
                        String attributeName = pathElements[pathElements.length - 1];
                        handler.setWarningMessage(
                            CmsContentDefinition.extractIndex(attributeName),
                            warning.getValue(),
                            m_formTabPanel);
                    }
                }
            }
        }
        if (validationResult.hasErrors(entityId)) {
            for (Entry<String[], String> error : validationResult.getErrors(entityId).entrySet()) {
                String[] pathElements = error.getKey();
                CmsAttributeHandler handler = m_rootHandler.getHandlerByPath(pathElements);
                if (handler != null) {
                    String attributeName = pathElements[pathElements.length - 1];
                    handler.setErrorMessage(
                        CmsContentDefinition.extractIndex(attributeName),
                        error.getValue(),
                        m_formTabPanel);
                }
            }
            m_validationContext.addInvalidEntity(entityId);
        } else {
            m_validationContext.addValidEntity(entityId);
        }
        ValueChangeEvent.fire(this, m_validationContext);
        m_validating = false;
    }
88196
private void doText(Element received, Element source) {
        if (log.isDebugEnabled()) {
            log.debug("Validating node value for element: " + received.getLocalName());
        }

        String receivedText = DomUtils.getTextValue(received);
        String sourceText = DomUtils.getTextValue(source);

        if (receivedText != null) {
            Assert.isTrue(sourceText != null,
                    ValidationUtils.buildValueMismatchErrorMessage("Node value not equal for element '"
                            + received.getLocalName() + "'", null, receivedText.trim()));

            Assert.isTrue(receivedText.trim().equals(sourceText.trim()),
                    ValidationUtils.buildValueMismatchErrorMessage("Node value not equal for element '"
                            + received.getLocalName() + "'", sourceText.trim(),
                            receivedText.trim()));
        } else {
            Assert.isTrue(sourceText == null,
                    ValidationUtils.buildValueMismatchErrorMessage("Node value not equal for element '"
                            + received.getLocalName() + "'", sourceText.trim(), null));
        }

        if (log.isDebugEnabled()) {
            log.debug("Node value '" + receivedText.trim() + "': OK");
        }
    }
569060
function (element) {
            var submittable = /^(?:input|select|textarea|keygen)/i;
            var submitterTypes = /^(?:submit|button|image|reset|file)$/i;
            var type = element.type;
            var checkableTypes = /^(?:checkbox|radio)$/i;

            return element.name && !element.disabled && submittable.test(element.nodeName)
                    && !submitterTypes.test(type) && (element.checked || !checkableTypes.test(type));
        }
656364
public function validate() {

		$result = parent::validate();

		// Confirm that the current search suggestion matches the minimum autocomplete length and doesn't already exist.

		if($result->isValid() && (strlen($this->Term) < 3)) {
			$result->addError('Minimum autocomplete length required!');
		}
		else if($result->isValid() && ExtensibleSearchSuggestion::get_one(ExtensibleSearchSuggestion::class, array(
			'ID != ?' => (int)$this->ID,
			'Term = ?' => $this->Term,
			'ExtensibleSearchPageID = ?' => $this->ExtensibleSearchPageID
		))) {
			$result->addError('Suggestion already exists!');
		}

		// Allow extension customisation.

		$this->extend('validateExtensibleSearchSuggestion', $result);
		return $result;
	}
579785
def _get_aria_autocomplete(self, field):
        

        tag_name = field.get_tag_name()
        input_type = None
        if field.has_attribute('type'):
            input_type = field.get_attribute('type').lower()
        if (
            (tag_name == 'TEXTAREA')
            or (
                (tag_name == 'INPUT')
                and (not (
                    (input_type == 'button')
                    or (input_type == 'submit')
                    or (input_type == 'reset')
                    or (input_type == 'image')
                    or (input_type == 'file')
                    or (input_type == 'checkbox')
                    or (input_type == 'radio')
                    or (input_type == 'hidden')
                ))
            )
        ):
            value = None
            if field.has_attribute('autocomplete'):
                value = field.get_attribute('autocomplete').lower()
            else:
                form = self.parser.find(field).find_ancestors(
                    'form'
                ).first_result()
                if (form is None) and (field.has_attribute('form')):
                    form = self.parser.find(
                        '#' + field.get_attribute('form')
                    ).first_result()
                if (form is not None) and (form.has_attribute('autocomplete')):
                    value = form.get_attribute('autocomplete').lower()
            if value == 'on':
                return 'both'
            elif (
                (field.has_attribute('list'))
                and (self.parser.find(
                    'datalist[id="' + field.get_attribute('list') + '"]'
                ).first_result() is not None)
            ):
                return 'list'
            elif value == 'off':
                return 'none'
        return None
397800
protected function autocompletefield() {

		if ( ! $this->autocompleted) {

			$fieldname = $this->get('name', null);

			if ($fieldname !== null && ($autovalue = $this->form->autovalue($fieldname)) !== null) {

				#
				# The checkbox is simply a switch for a value. So if the
				# autocomplete value is equal to the field's current value then
				# the field is checked. Otherwise the field is unchecked.
				#

				$value = $this->get('value', 'freia:no-value');
				if ($value !== 'freia:no-value') {
					if ($value == $autovalue) {
						$this->checked();
					}
					else { # autovalue != value && autovalue !== null
						$this->unchecked();
					}
				}
			}

			$this->autocompleted = true;
		}
	}
1187057
protected function registerElements() {
		$this->action_mode = self::ACTION_GET;
		
		$validatorBool = new \OWeb\utils\inputManagement\validators\Boolean();
		
		$jsString = new \OWeb\utils\inputManagement\validators\JsString();
		
		$this->setAction('refresh');
		
		$active = new \Controller\OWeb\Helpers\Form\Elements\Text();
		$active->init();
		$active->setName('active');
		$active->setTitle('Active');
		$active->setDescription("Which panel is currently open.");
		$active->addValidator(new \OWeb\utils\inputManagement\validators\Integer());
		$active->addValidator(new \OWeb\utils\inputManagement\validators\CanBeEmpty());
		$active->setVal(0);
		$this->addDisplayElement($active);
		
		$animate = new \Controller\OWeb\Helpers\Form\Elements\Text();
		$animate->init();
		$animate->setName('animate');
		$animate->setTitle('Animate');
		$animate->setVal('Animate');
		$animate->addValidator($jsString);
		$animate->setDescription("If and how to animate changing panels.");
		//$this->addDisplayElement($animate);
		
		$collapsible = new \Controller\OWeb\Helpers\Form\Elements\Radio();
		$collapsible->init();
		$collapsible->setName('collapsible');
		$collapsible->setTitle('Collapsible');
		$collapsible->add("true", "true");
		$collapsible->add("false", "false");
		$collapsible->addValidator($validatorBool);
		$collapsible->setVal('true');
		$collapsible->setDescription("hether all the sections can be closed at once. Allows collapsing the active section");
		$this->addDisplayElement($collapsible);
		
		$disabled = new \Controller\OWeb\Helpers\Form\Elements\Radio();
		$disabled->init();
		$disabled->setName('disabled');
		$disabled->setTitle('Disabled');
		$disabled->add("true", "true");
		$disabled->add("false", "false");
		$disabled->addValidator($validatorBool);
		$disabled->setVal('false');
		$disabled->setDescription("Disables the accordion if set to true.");
		$this->addDisplayElement($disabled);
		
		$event = new \Controller\OWeb\Helpers\Form\Elements\Text();
		$event->init();
		$event->setName('event');
		$event->setTitle('Event');
		$event->setVal('click');
		$event->addValidator($jsString);
		$event->setDescription("The event that accordion headers will react to in order to activate the associated panel. Multiple events can be specified, separated by a space.");
		$this->addDisplayElement($event);
		
		$heightStyle = new \Controller\OWeb\Helpers\Form\Elements\Select();
		$heightStyle->init();
		$heightStyle->setName('heightStyle');
		$heightStyle->setTitle('Height Style');
		$heightStyle->add("Auto", "auto");
		$heightStyle->add("Fill", "fill");
		$heightStyle->add("Content", "content");
		$heightStyle->addValidator($jsString);
		$heightStyle->setVal('auto');
		$heightStyle->setDescription("Controls the height of the accordion and each panel.");
		$this->addDisplayElement($heightStyle);
		
		$submit = new \Controller\OWeb\Helpers\Form\Elements\Submit();
		$submit->init();
		$submit->setVal("Refresh");
		$this->addDisplayElement($submit);
	}
845886
def submit(self):
        
        def submit_element():
            """
            Wrapper to submit element
            """
            return self.element.submit()
        self.execute_and_handle_webelement_exceptions(submit_element, 'send keys')
        return self
528755
def form_validation_response(self, e):
        
        resp = rc.BAD_REQUEST
        resp.write(' '+str(e.form.errors))
        return resp
1193584
function addValidElements(validElements) {
        var ei, el, ai, al, matches, element, attr, attrData, elementName, attrName, attrType, attributes, attributesOrder,
          prefix, outputName, globalAttributes, globalAttributesOrder, key, value,
          elementRuleRegExp = /^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/,
          attrRuleRegExp = /^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,
          hasPatternsRegExp = /[*?+]/;

        if (validElements) {
          // Split valid elements into an array with rules
          validElements = split(validElements, ',');

          if (elements['@']) {
            globalAttributes = elements['@'].attributes;
            globalAttributesOrder = elements['@'].attributesOrder;
          }

          // Loop all rules
          for (ei = 0, el = validElements.length; ei < el; ei++) {
            // Parse element rule
            matches = elementRuleRegExp.exec(validElements[ei]);
            if (matches) {
              // Setup local names for matches
              prefix = matches[1];
              elementName = matches[2];
              outputName = matches[3];
              attrData = matches[5];

              // Create new attributes and attributesOrder
              attributes = {};
              attributesOrder = [];

              // Create the new element
              element = {
                attributes: attributes,
                attributesOrder: attributesOrder
              };

              // Padd empty elements prefix
              if (prefix === '#') {
                element.paddEmpty = true;
              }

              // Remove empty elements prefix
              if (prefix === '-') {
                element.removeEmpty = true;
              }

              if (matches[4] === '!') {
                element.removeEmptyAttrs = true;
              }

              // Copy attributes from global rule into current rule
              if (globalAttributes) {
                for (key in globalAttributes) {
                  attributes[key] = globalAttributes[key];
                }

                attributesOrder.push.apply(attributesOrder, globalAttributesOrder);
              }

              // Attributes defined
              if (attrData) {
                attrData = split(attrData, '|');
                for (ai = 0, al = attrData.length; ai < al; ai++) {
                  matches = attrRuleRegExp.exec(attrData[ai]);
                  if (matches) {
                    attr = {};
                    attrType = matches[1];
                    attrName = matches[2].replace(/::/g, ':');
                    prefix = matches[3];
                    value = matches[4];

                    // Required
                    if (attrType === '!') {
                      element.attributesRequired = element.attributesRequired || [];
                      element.attributesRequired.push(attrName);
                      attr.required = true;
                    }

                    // Denied from global
                    if (attrType === '-') {
                      delete attributes[attrName];
                      attributesOrder.splice(inArray(attributesOrder, attrName), 1);
                      continue;
                    }

                    // Default value
                    if (prefix) {
                      // Default value
                      if (prefix === '=') {
                        element.attributesDefault = element.attributesDefault || [];
                        element.attributesDefault.push({ name: attrName, value: value });
                        attr.defaultValue = value;
                      }

                      // Forced value
                      if (prefix === ':') {
                        element.attributesForced = element.attributesForced || [];
                        element.attributesForced.push({ name: attrName, value: value });
                        attr.forcedValue = value;
                      }

                      // Required values
                      if (prefix === '<') {
                        attr.validValues = makeMap(value, '?');
                      }
                    }

                    // Check for attribute patterns
                    if (hasPatternsRegExp.test(attrName)) {
                      element.attributePatterns = element.attributePatterns || [];
                      attr.pattern = patternToRegExp(attrName);
                      element.attributePatterns.push(attr);
                    } else {
                      // Add attribute to order list if it doesn't already exist
                      if (!attributes[attrName]) {
                        attributesOrder.push(attrName);
                      }

                      attributes[attrName] = attr;
                    }
                  }
                }
              }

              // Global rule, store away these for later usage
              if (!globalAttributes && elementName == '@') {
                globalAttributes = attributes;
                globalAttributesOrder = attributesOrder;
              }

              // Handle substitute elements such as b/strong
              if (outputName) {
                element.outputName = elementName;
                elements[outputName] = element;
              }

              // Add pattern or exact element
              if (hasPatternsRegExp.test(elementName)) {
                element.pattern = patternToRegExp(elementName);
                patternElements.push(element);
              } else {
                elements[elementName] = element;
              }
            }
          }
        }
      }
1014308
def validate_element(self, value):
        
        # If value is str is it considered valid.  Satisfies "required=True".
        if isinstance(value, bytes):
            try:
                six.text_type(value, 'UTF-8')
            except UnicodeDecodeError as err:
                try:
                    _ = self.name
                except AttributeError:
                    validation_error = ValidationError(
                        'Field encountered non-UTF-8 string %r: %s' % (value,
                                                                       err))
                else:
                    validation_error = ValidationError(
                        'Field %s encountered non-UTF-8 string %r: %s' % (
                            self.name, value, err))
                    validation_error.field_name = self.name
                raise validation_error
        else:
            return super(StringField, self).validate_element(value)
        return value
784565
function defaultOnInputValidationResult(el, validationsResult, validatorName, stateEnum) {

        var errorDiv;

        // for radio buttons and checkboxes:  get the last element in group by name
        if ((el.nodeName.toLowerCase() === 'input' && (el.type === 'radio' || el.type === 'checkbox'))) {

            var getAllByName = el.parentNode.querySelectorAll('input[name="' + el.name + '"]');

            el = getAllByName.item(getAllByName.length - 1);
        }

        if (validationsResult.stateEnum === stateEnum.invalid) {

            errorDiv = getExistingErrorDiv(el);
            if (errorDiv) {
                errorDiv.textContent = validationsResult.message;
            } else {
                appendNewErrorDiv(el, validationsResult.message);
            }

            el.style.borderStyle = "solid";
            el.style.borderColor = "#ff0000";
            $$.addClass(el, "vivalid-error-input");
        } else {
            errorDiv = getExistingErrorDiv(el);
            if (errorDiv) {
                errorDiv.parentNode.removeChild(errorDiv);
                el.style.borderStyle = "";
                el.style.borderColor = "";
                $$.removeClass(el, "vivalid-error-input");
            }
        }

        function getExistingErrorDiv(el) {
            if (el.nextElementSibling && el.nextElementSibling.className === "vivalid-error") {
                return el.nextElementSibling;
            }

        }

        function appendNewErrorDiv(el, message) {
            errorDiv = document.createElement("DIV");
            errorDiv.className = "vivalid-error";
            errorDiv.style.color = "#ff0000";
            var t = document.createTextNode(validationsResult.message);
            errorDiv.appendChild(t);
            el.parentNode.insertBefore(errorDiv, el.nextElementSibling);
        }

    }
467990
private function setValidation()
    {
        $this->sourceDomainsElement->addValidator(new CspHeaderValidator(['sourceElement' => $this->sourceElement]));
        $this->sourceElement->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty'));
    }