Language

Maxlength and Minlength Attributes


When the maxlength and minlength attributes are used together on an <input> element. In this case, the value of the maxlength attribute must be equal to or greater than the value of the minlength attribute.

The maxlength attribute controls the maximum length of the <input> element's value.

The minlength attribute is used to control the minimum value of the <input> element.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form>
        <label for="full-name">Full Name</label>
        <input type="text" id="full-name" maxlength="25" minlength="3"> 
        <br><br>
        <input type="submit" value="Submit">
    </form>
</body>
</html>