Advertisement
Home Open Editor ❯

HTML minlength Attribute

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>

Try this code ❯

Meaning

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


Standard Syntax

<element minlength="number">


Applies to:

The minlength attribute can be used on the following element:


Advertisement

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>

Try this code ❯

Home Open Editor ❯
Advertisement