The minlength
attribute defines the minimum string length that the user can enter into an <input>
or <textarea>
. The attribute must have an integer value of 0 or higher.
The length is measured in UTF-16 code units, which (for most scripts) is equivalent to the number of characters. If no minlength
is specified, or an invalid value is specified, the input has no minimum length. This value must be less than or equal to the value of maxlength, otherwise the value will never be valid, as it is impossible to meet both criteria.
The input will fail constraint validation if the length of the text value of the field is less than minlength UTF-16 code units long, with validityState.tooShort
returning true
. Constraint validation is only applied when the value is changed by the user. Once submission fails, some browsers will display an error message indicating the minimum length required and the current length.
minlength
does not imply required
; an input only violates a minlength
constraint if the user has input a value. If an input is not required
, an empty string can be submitted even if minlength
is set.