Open In App
Related Articles

HTML | minlength Attribute

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The HTML minlength attribute is used to specify the minimum number of characters (as UTF-16 code) the user enters into the input field or text area. Integer value must start with 0 or higher.

Syntax: 

<Element minlength="numeric">

Applicable: 

  • <input>
  • <textarea>

Attribute Value:  

  • number: It contains the numeric value i.e. 0 or higher.

Example:  

HTML

<!DOCTYPE html>
<html>
<head>
    <title>
        HTML | minlength Attribute
    </title>
</head>
<body style="text-align: center;"
    <h1 style="color:green;">
        GeeksForGeeks
    </h1>
    <h2>minlength attribute</h2>
    <form action="">
        Username:
        <input type="text"
                name="usrname"
                minlength="10">
        <br><br>
        Password:
        <input type="text"
                name="password"
                maxlength="10">
        <br><br>
        <input type="submit"
                value="Submit">
    </form>
</body>
</html>

                    

Output:  

Supported Browsers: The browser supported by HTML minlength attribute are listed below:  

  • Apple Safari 10.1 and above
  • Google Chrome 40 and above
  • Edge 17 and above
  • Firefox 51 and above
  • Opera 27 and above


Last Updated : 24 Aug, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads