HTML minlength Attribute

❮ HTML Attributes


<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">


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

Standard Syntax

<element minlength="number">

Browser Support


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


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