HTML minlength Attribute

❮ HTML Attributes

Example

<form action="action.php">
	<label for="username">Username:</label>
	<input type="text" id="username" name="username" minlength="6" maxlength="10"><br><br>
	<label for="pasw">Password:</label>
	<input type="password" id="pasw" name="password" minlength="8" maxlength="16"><br><br>
	<input type="submit" value="Submit">
</form>

Meaning

The minlength attribute specifies the mainimum content length that can be entered in a text form control.




Standard Syntax

<element minlength="number">



Browser Support




Status




Applies to:

The minlength attribute can be used on the following element:

Element Attribute
<input> minlength
<textarea> minlength






Attribute Values

Value Description
number Specifies the minimum number of characters allowed.



More Examples

Example

<form action="action.php">
	<label for="demo">textarea demo:</label>
	<textarea minlength="15" id="demo" name="textareaText">
	Hello world!
	</textarea>
	<br><br>
	<input type="submit" value="Submit">
</form>
❮ HTML Attributes