Module org.htmlunit

Class HtmlNumberInput

All Implemented Interfaces:
Serializable, Cloneable, DisabledElement, SelectableTextInput, LabelableElement, SubmittableElement, ValidatableHtmlElement, Element, Node

public class HtmlNumberInput extends HtmlSelectableTextInput implements LabelableElement
Wrapper for the HTML element "input" with type is "number".
Author:
Ahmed Ashour, Ronald Brill, Frank Danek, Anton Demydenko, Raik Bieniek, Michael Lueck
See Also:
  • Method Details

    • isSubmittableByEnter

      protected boolean isSubmittableByEnter()
      Returns true if clicking Enter (ASCII 10, or '\n') should submit the enclosed form (if any). The default implementation returns false.
      Overrides:
      isSubmittableByEnter in class HtmlElement
      Returns:
      true if clicking Enter should submit the enclosed form (if any)
    • setDefaultChecked

      public void setDefaultChecked(boolean defaultChecked)
      Sets the default checked state to use when this element gets reset, if applicable. The default implementation is empty; only checkboxes and radio buttons really care what the default checked value is.
      Specified by:
      setDefaultChecked in interface SubmittableElement
      Parameters:
      defaultChecked - the default checked state to use when this element gets reset, if applicable
      See Also:
    • doType

      protected void doType(char c, boolean lastType)
      Performs the effective type action, called after the keyPress event and before the keyUp event.
      Overrides:
      doType in class HtmlSelectableTextInput
      Parameters:
      c - the character you with to simulate typing
      lastType - is this the last character to type
    • getValue

      public String getValue()
      Returns the value.
      Overrides:
      getValue in class HtmlInput
      Returns:
      the value
    • setValue

      public void setValue(String newValue)
      Sets the value.
      Overrides:
      setValue in class HtmlSelectableTextInput
      Parameters:
      newValue - the new value
    • hasRangeOverflowValidityState

      public boolean hasRangeOverflowValidityState()
      Returns whether the element's value exceeds the maximum allowed value. A raw value that isn't even a well-formed number is hasBadInputValidityState()'s concern, not a range violation.
      Specified by:
      hasRangeOverflowValidityState in interface ValidatableHtmlElement
      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

      public boolean hasRangeUnderflowValidityState()
      Returns whether the element's value is less than the minimum allowed value. See hasRangeOverflowValidityState() for the malformed-value / badInput distinction.
      Specified by:
      hasRangeUnderflowValidityState in interface ValidatableHtmlElement
      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
    • isStepMismatchValidityState

      public boolean isStepMismatchValidityState()
      Returns whether the element's value does not satisfy the step constraint. See hasRangeOverflowValidityState() for the malformed-value / badInput distinction.
      Specified by:
      isStepMismatchValidityState in interface ValidatableHtmlElement
      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
    • hasBadInputValidityState

      public boolean hasBadInputValidityState()
      Returns whether the user has provided input that the browser is unable to convert. The new home for the malformed-value case that used to make hasRangeOverflowValidityState()/hasRangeUnderflowValidityState()/ isStepMismatchValidityState() all incorrectly return true simultaneously.
      Specified by:
      hasBadInputValidityState in interface ValidatableHtmlElement
      Returns:
      true if the user has provided input that the browser is unable to convert