HTML <input> 标签的 minlength 属性
HTML <input> 标签
实例
最小长度为 8 个字符的 <input> 元素:
<form action="/action_page.php"><label for="password">Password:</label><input type="password" id="password" name="password" minlength="8"><br><br><input type="submit" value="Submit"></form>
定义和用法
minlength 属性规定输入字段中所需的最小字符数。
注释:minlength 属性可以与以下类型一起使用:
- text
- search
- url
- tel
- password
浏览器支持
表格中的数字注明了完全支持该属性的首个浏览器版本。
| 属性 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| minlength | 40.0 | 17.0 | 51.0 | 10.1 | 27.0 |
语法
<input minlength="number">
属性值
| 值 | 描述 |
|---|---|
| number | <input> 元素中所需的最小字符数。 |

