HTML <input> minlength 屬性
定義和用法
minlength
屬性規定 <input> 元素中所需的最小字符數。
注意:minlength
屬性可用于以下輸入類型:
- text
- search
- url
- tel
- password
實例
最小長度為 8 個字符的 <input> 元素:
<form action="/action_page.php"> <label for="password">密碼:</label> <input type="password" id="password" name="password" minlength="8"><br><br> <input type="submit" value="提交"> </form>
語法
<input minlength="number">
屬性值
值 | 描述 |
---|---|
number | <input> 元素中所需的最少字符數。 |
瀏覽器支持
表中的數字注明了首個完全支持該屬性的瀏覽器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
40.0 | 17.0 | 51.0 | 10.1 | 27.0 |