HTML input maxlength attribute
Examples
The maximum length is 10 characters <input> element:
<form action="demo_form.php">
Username: <input type="text" name="usrname" maxlength="10"><br>
<input type="submit" value="提交">
</form>
Username: <input type="text" name="usrname" maxlength="10"><br>
<input type="submit" value="提交">
</form>
try it"
Browser Support
All major browsers support maxlength attribute.
Definition and Usage
maxlength attribute specifies the <input> elements maximum number of characters allowed.
Differences between HTML 4.01 and HTML5
no.
grammar
<input maxlength="number">
Property Value
值 | 描述 |
---|---|
number | 在 <input> 元素中允许的最大字符数。 |
HTML <input> tag