Module org.htmlunit

Interface ValidatableHtmlElement

All Known Implementing Classes:
HtmlButton, HtmlButtonInput, HtmlCheckBoxInput, HtmlColorInput, HtmlDateInput, HtmlDateTimeLocalInput, HtmlEmailInput, HtmlFieldSet, HtmlFileInput, HtmlHiddenInput, HtmlImageInput, HtmlInput, HtmlMonthInput, HtmlNumberInput, HtmlObject, HtmlOutput, HtmlPasswordInput, HtmlRadioButtonInput, HtmlRangeInput, HtmlResetInput, HtmlSearchInput, HtmlSelect, HtmlSelectableTextInput, HtmlSubmitInput, HtmlTelInput, HtmlTextArea, HtmlTextInput, HtmlTimeInput, HtmlUrlInput, HtmlWeekInput

public interface ValidatableHtmlElement
An HtmlElement that supports client-side validation using the Constraint Validation API. This uses ValidatableHTMLElement.
Author:
Ronald Brill
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns the message describing bad input (the user has provided input that the browser is unable to convert, e.g. non-numeric text typed into a number input).
    Returns the raw custom validity message set via setCustomValidity(String), or the empty string if none has been set.
    default String
    Returns the message describing a pattern mismatch (the element's value does not match the constraint specified by the pattern attribute).
    default String
    Returns the message describing a range overflow (the element's value is greater than the maximum specified by the max attribute).
    default String
    Returns the message describing a range underflow (the element's value is less than the minimum specified by the min attribute).
    default String
    Returns the message describing a step mismatch (the element's value does not satisfy the constraint specified by the step attribute).
    default String
    Returns the message describing a too-long value (the element's value is longer than the maximum length specified by the maxlength attribute).
    default String
    Returns the message describing a too-short value (the element's value is shorter than the minimum length specified by the minlength attribute).
    default String
    Returns the message describing a type mismatch (the element's value is not in the syntax required by its type, e.g.
    default String
    Returns the (potentially control-specific) message describing the currently failing constraint, in spec priority order: customError, patternMismatch, rangeOverflow, rangeUnderflow, stepMismatch, tooLong, tooShort, typeMismatch, badInput, valueMissing.
    default String
    Returns the message describing a missing required value (the element has a required attribute but no value).
    default boolean
    Returns whether the user has provided input that the browser is unable to convert.
    default boolean
    Returns whether the element's value does not match the specified pattern.
    default boolean
    Returns whether the element's value exceeds the maximum allowed value.
    default boolean
    Returns whether the element's value is less than the minimum allowed value.
    default boolean
    Returns whether the element's value has a type mismatch.
    boolean
    Returns whether the element has a custom validity message.
    default boolean
    Returns whether the element's value does not satisfy the step constraint.
    default boolean
    Returns whether the element's value exceeds the maximum allowed length.
    default boolean
    Returns whether the element's value is shorter than the minimum required length.
    boolean
    Returns whether the element satisfies all validation constraints.
    default boolean
    Returns whether the element is missing a required value.
    void
    Sets the custom validity message for the element.
    boolean
    Returns whether the element is a candidate for constraint validation.
  • Method Details

    • willValidate

      boolean willValidate()
      Returns whether the element is a candidate for constraint validation.
      Returns:
      whether the element is a candidate for constraint validation
    • setCustomValidity

      void setCustomValidity(String message)
      Sets the custom validity message for the element.
      Parameters:
      message - the new message
    • hasBadInputValidityState

      default boolean hasBadInputValidityState()
      Returns whether the user has provided input that the browser is unable to convert.
      Returns:
      true if the user has provided input that the browser is unable to convert
    • isCustomErrorValidityState

      boolean isCustomErrorValidityState()
      Returns whether the element has a custom validity message.
      Returns:
      true if the element's custom validity message has been set to a non-empty string by calling setCustomValidity(String)
    • hasPatternMismatchValidityState

      default boolean hasPatternMismatchValidityState()
      Returns whether the element's value does not match the specified pattern.
      Returns:
      true if the value does not match the specified pattern; if true, the element matches the :invalid CSS pseudo-class
    • isStepMismatchValidityState

      default boolean isStepMismatchValidityState()
      Returns whether the element's value does not satisfy the step constraint.
      Returns:
      true if the value does not fit the rules determined by the step attribute; if true, the element matches the :invalid and :out-of-range CSS pseudo-classes
    • isTooLongValidityState

      default boolean isTooLongValidityState()
      Returns whether the element's value exceeds the maximum allowed length.
      Returns:
      true if the value is longer than the maximum length specified by the maxlength attribute; if true, the element matches the :invalid CSS pseudo-class
    • isTooShortValidityState

      default boolean isTooShortValidityState()
      Returns whether the element's value is shorter than the minimum required length.
      Returns:
      true if the value is shorter than the minimum length specified by the minlength attribute; if true, the element matches the :invalid CSS pseudo-class
    • hasTypeMismatchValidityState

      default boolean hasTypeMismatchValidityState()
      Returns whether the element's value has a type mismatch.
      Returns:
      true if the value is not in the required syntax (for example, for email or url); if true, the element matches the :invalid CSS pseudo-class
    • hasRangeOverflowValidityState

      default boolean hasRangeOverflowValidityState()
      Returns whether the element's value exceeds the maximum allowed value.
      Returns:
      true if the value is greater than the maximum specified by the max attribute; if true, the element matches the :invalid and :out-of-range CSS pseudo-classes
    • hasRangeUnderflowValidityState

      default boolean hasRangeUnderflowValidityState()
      Returns whether the element's value is less than the minimum allowed value.
      Returns:
      true if the value is less than the minimum specified by the min attribute; if true, the element matches the :invalid and :out-of-range CSS pseudo-classes
    • isValidValidityState

      boolean isValidValidityState()
      Returns whether the element satisfies all validation constraints.
      Returns:
      true if the element is valid; if true, the element matches the :valid CSS pseudo-class, otherwise the :invalid CSS pseudo-class
    • isValueMissingValidityState

      default boolean isValueMissingValidityState()
      Returns whether the element is missing a required value.
      Returns:
      true if the element has a required attribute but no value; if true, the element matches the :invalid CSS pseudo-class
    • getCustomValidity

      String getCustomValidity()
      Returns the raw custom validity message set via setCustomValidity(String), or the empty string if none has been set.
      Returns:
      the custom validity message
    • getValidationMessage

      default String getValidationMessage()
      Returns the (potentially control-specific) message describing the currently failing constraint, in spec priority order: customError, patternMismatch, rangeOverflow, rangeUnderflow, stepMismatch, tooLong, tooShort, typeMismatch, badInput, valueMissing. Returns "" if barred from validation or currently valid.
      Returns:
      the validation message
    • getPatternMismatchMessage

      default String getPatternMismatchMessage()
      Returns the message describing a pattern mismatch (the element's value does not match the constraint specified by the pattern attribute). Generic, uniform wording -- override in a concrete class that can interpolate control-specific details (e.g. the pattern itself or a title hint) into the message.
      Returns:
      the pattern mismatch message
    • getRangeOverflowMessage

      default String getRangeOverflowMessage()
      Returns the message describing a range overflow (the element's value is greater than the maximum specified by the max attribute). Generic, uniform wording -- override in a concrete class that can interpolate the actual max value into the message.
      Returns:
      the range overflow message
    • getRangeUnderflowMessage

      default String getRangeUnderflowMessage()
      Returns the message describing a range underflow (the element's value is less than the minimum specified by the min attribute). Generic, uniform wording -- override in a concrete class that can interpolate the actual min value into the message.
      Returns:
      the range underflow message
    • getStepMismatchMessage

      default String getStepMismatchMessage()
      Returns the message describing a step mismatch (the element's value does not satisfy the constraint specified by the step attribute). Generic fallback wording -- real browsers typically also name the two nearest step-aligned valid values, which this default does not attempt to compute; override in a concrete class if that level of detail is needed.
      Returns:
      the step mismatch message
    • getTooLongMessage

      default String getTooLongMessage()
      Returns the message describing a too-long value (the element's value is longer than the maximum length specified by the maxlength attribute). Generic, uniform wording -- override in a concrete class that can interpolate the actual maxlength and current length into the message.
      Returns:
      the too-long message
    • getTooShortMessage

      default String getTooShortMessage()
      Returns the message describing a too-short value (the element's value is shorter than the minimum length specified by the minlength attribute). Generic, uniform wording -- override in a concrete class that can interpolate the actual minlength and current length into the message.
      Returns:
      the too-short message
    • getTypeMismatchMessage

      default String getTypeMismatchMessage()
      Returns the message describing a type mismatch (the element's value is not in the syntax required by its type, e.g. email or url). Generic, uniform wording -- override in a concrete class that can produce a type-specific message.
      Returns:
      the type mismatch message
    • getBadInputMessage

      default String getBadInputMessage()
      Returns the message describing bad input (the user has provided input that the browser is unable to convert, e.g. non-numeric text typed into a number input). Generic, uniform wording.
      Returns:
      the bad input message
    • getValueMissingMessage

      default String getValueMissingMessage()
      Returns the message describing a missing required value (the element has a required attribute but no value). Generic, uniform wording.
      Returns:
      the value missing message