Module org.htmlunit

Interface ValidatableHTMLElement


public interface ValidatableHTMLElement
An HTMLElement that supports client-side validation using the Constraint Validation API. This works together with ValidatableHtmlElement.

Shared implementation of the HTML Constraint Validation API's checkValidity()/reportValidity() behavior, for JS host objects wrapping an ValidatableHtmlElement. Centralizes 'invalid' event dispatch and the interactive-vs-static distinction between the two methods (reportValidity() additionally focuses the element on failure) so this isn't duplicated per element type -- each implementing class only needs to supply the underlying DOM element.

Author:
Ronald Brill
See Also:
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static boolean
    Statically validates the underlying element's constraints, firing a cancelable 'invalid' event on it if invalid.
    static boolean
    Interactively validates -- same static check and 'invalid' event as doCheckValidity(HtmlElement), but additionally focuses the element if it's invalid.
    static String
    Returns the validation message describing the currently failing constraint, or "" if valid or barred from validation.
  • Method Details

    • doCheckValidity

      static boolean doCheckValidity(HtmlElement elem)
      Statically validates the underlying element's constraints, firing a cancelable 'invalid' event on it if invalid. Does not move focus.
      Parameters:
      elem - the HtmlElement to work on
      Returns:
      true if valid or barred from validation, false otherwise
    • doReportValidity

      static boolean doReportValidity(HtmlElement elem)
      Interactively validates -- same static check and 'invalid' event as doCheckValidity(HtmlElement), but additionally focuses the element if it's invalid.
      Parameters:
      elem - the HtmlElement to work on
      Returns:
      true if valid or barred from validation, false otherwise
    • getValidationMessage

      static String getValidationMessage(HtmlElement elem)
      Returns the validation message describing the currently failing constraint, or "" if valid or barred from validation.
      Parameters:
      elem - the HtmlElement to work on
      Returns:
      the validation message