A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/minLength below:

HTMLInputElement: minLength property - Web APIs

HTMLInputElement: minLength property

Baseline Widely available

The minLength property of the HTMLInputElement interface indicates the minimum number of characters (in UTF-16 code units) required for the value of the <input> element to be valid. It reflects the element's minlength attribute. -1 means there is no minimum length requirement.

Note: If the input has a value, and that value has fewer characters than the minlength attribute requires, the element is considered invalid and the ValidityState object's tooShort property will be true.

Value

A number representing the element's minlength if present or -1.

Example

Given the following HTML:

<p>
  <label for="password">Your password</label>
  <input id="password" type="password" minlength="8" maxlength="20" />
</p>

You can use the minLength property to retrieve or set the <input>'s minlength attribute value:

const inputElement = document.querySelector("#password");
console.log(`Element's minLength: ${inputElement.minLength}`); // "Element's minlength: 8"
inputElement.minLength = 12; // updates the element's minlength attribute value
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4