The <input> element
Methods
The following methods are provided by the HTMLInputElement
interface which represents <input>
elements in the DOM. Also available are those methods specified by the parent interfaces, HTMLElement
, Element
, Node
, and EventTarget
.
checkValidity()
-
Returns
true
if the element's value passes validity checks; otherwise, returnsfalse
and fires aninvalid
event at the element. reportValidity()
-
Returns
true
if the element's value passes validity checks; otherwise, returnsfalse
, fires aninvalid
event at the element, and (if the event isn't canceled) reports the problem to the user. select()
-
Selects the entire content of the
<input>
element, if the element's content is selectable. For elements with no selectable text content (such as a visual color picker or calendar date input), this method does nothing. setCustomValidity()
-
Sets a custom message to display if the input element's value isn't valid.
setRangeText()
-
Sets the contents of the specified range of characters in the input element to a given string. A
selectMode
parameter is available to allow controlling how the existing content is affected. setSelectionRange()
-
Selects the specified range of characters within a textual input element. Does nothing for inputs which aren't presented as text input fields.
stepDown()
-
Decrements the value of a numeric input by one, by default, or by the specified number of units.
stepUp()
-
Increments the value of a numeric input by one or by the specified number of units.